I have the following code to receive SMS by my application:
public class SMSReceiver extends BroadcastReceiver
{
@Override
public void onReceive(Context context, Intent intent)
{
...
In order to test it, I have to send an SMS with telnet (and I can do nothing with Android x86).
Can I call this onReceive
programmatically for ex., when button is pressed or application is started? What kind of parameters should I pass (i.e. where tel number should be? text of the message etc.)?
Upd. I found this answer - https://stackoverflow.com/a/12338541/604388. If I follow that code, i.e.:
intent.setClassName("com.android.mms",
"com.android.mms.transaction.SmsReceiverService");
context.startService(intent);
then standard event is fired (i.e. message is received by standard android Messaging app), but my code at onReceive
doesn't work.
If I replace it with:
// intent.setClassName("com.android.mms",
// "com.android.mms.transaction.SmsReceiverService");
context.sendBroadcast(intent);
then my code at onReceive
works, but not standard android app.
How can I fix it?