简体   繁体   English

如何在Rooted android设备中使用shell命令读取SMS?

[英]How to read the SMS using shell commands In Rooted android Device?

Hi i am developing application to read SMS using shell Commands (Only for Rooted Device ) 嗨,我正在开发使用shell命令读取SMS的应用程序(仅适用于Rooted Device)

Example Code 范例程式码

  • Runtime.getRuntime().exec("su -c \\"mkdir /sdcard/testdir\\"").waitFor(); Runtime.getRuntime()。exec(“ su -c \\” mkdir / sdcard / testdir \\“”)。waitFor(); --> To create directory ->创建目录
  • Runtime.getRuntime().exec("su"); 调用Runtime.getRuntime()EXEC( “ス”)。 --> Super User Permission ->超级用户权限
  • Runtime.getRuntime().exec("??"); 调用Runtime.getRuntime()EXEC( “??”)。 --What is the Command To Read SMS -阅读短信的命令是什么

to read any value from content resolver you can access it via its uri. 要从内容解析器读取任何值,您可以通过其uri访问它。 like 喜欢

adb shell content query --uri content://sms --projection _id,address,body,read,date,type

pass this command in exec, you will get the result like 在exec中传递此命令,您将得到如下结果

Row: 0 _id=2, address=5554, body=Testing, read=1, date=1469533087074, type=2 行:0 _id = 2,地址= 5554,正文=正在测试,读取= 1,日期= 1469533087074,类型= 2

Row: 1 _id=1, address=5554, body=Hi, read=1, date=1469533011944, type=2 行:1 _id = 1,地址= 5554,正文= Hi,读取= 1,日期= 1469533011944,类型= 2

you can get specific sms using specific uri 您可以使用特定的uri获取特定的短信

content://sms/inbox 
content://sms/sent

it will helpful to you. 这将对您有所帮助。

Update 更新

you can run it from java code like 您可以从Java代码运行它,例如

Process process = Runtime.getRuntime().exec(new String[]{"su","-c","content query --uri content://sms --projection _id,address,body,read,date,type"});
BufferedReader bufferedReader = new BufferedReader(
new InputStreamReader(process.getInputStream()));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用java代码和AT命令从sim加密狗读取短信? - how to read sms from sim dongle using java code and AT commands? 如何在Android应用中运行重命名Shell命令 - How to run rename shell command in android app (rooted) 如何以编程方式在Android植根设备中将.raw文件转换为图像文件 - How to convert .raw file to image file in android rooted device programmatically 如何通过 appium 或 adb 更改 root android 设备的 IMEI 号码? - How to change the IMEI number of a rooted android device via appium or adb? 在已root用户的Android设备中复制系统文件 - Copy system files in rooted android device 在root用户设备上设置鼠标位置 - set mouse position on rooted android device 更改root设备上的日期(Android M) - Change date on rooted device (Android M) 如何在根仿真器上创建的android应用程序中运行终端命令? - How do you run terminal commands in a created android application on rooted emulator? 从android应用中的rooted设备中的android根文件系统中的/ dev / test文件中读写数据 - Read-Write data from /dev/test file in android root file system in rooted device from android app 如何重新启动非root用户的设备? - how to restart a non-rooted device?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM