[英]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.