Can I modify sms_body before sending SMS with built-in SMS Application?

让人想犯罪 __ 提交于 2020-01-06 06:53:28

问题


I know that we can send SMS via built-in SMS app in this way -

Intent sendIntent = new Intent(Intent.ACTION_VIEW);
sendIntent.setData(Uri.parse("sms:"));  
sendIntent.putExtra("sms_body", "");
startActivity(sendIntent);

But in my app, I want to modify some text of the sms body before sending it to the receiver. Is there any way?

I know I can do it with sendTextMessage method of SmsManager. I just want to know, is it also possible with the built-in SMS app?

Thank you.


回答1:


This is not possible, since SmsManager is part of frameworks. You cannot hijack it.

Edit: What you could do is change your app manifest to recieve ACTION_VIEW and uri sms: just like default messaging app and then when launched will change the body and launch the default messaging app.

Edit: Add below intent filter to your app and then "sms_body" extra from the intent and rebroadcast it this time by createChooser

 <intent-filter>
    <action android:name="android.intent.action.VIEW" />
    <action android:name="android.intent.action.SENDTO" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
    <data android:scheme="sms" />
    <data android:scheme="smsto" />
 </intent-filter>


来源:https://stackoverflow.com/questions/12185727/can-i-modify-sms-body-before-sending-sms-with-built-in-sms-application

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!