2

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?

Community
  • 1
  • 1
LA_
  • 19,823
  • 58
  • 172
  • 308

1 Answers1

0

Does this help? DDMS can emulate SMS messages, calles and locations. It's integrated with Eclipse set up for Android development and Android studio. You can find it at:

Window > Open Perspective > Other... > DDMS.

http://developer.android.com/tools/debugging/ddms.html

Aleksandar Stojadinovic
  • 4,851
  • 1
  • 34
  • 56