问题
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