Can I modify sms_body before sending SMS with buil

2019-09-03 17:39发布

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.

标签: android sms
1条回答
Evening l夕情丶
2楼-- · 2019-09-03 18:17

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>
查看更多
登录 后发表回答