by diki » Sun Nov 23, 2008 7:22 am
Hi Jagtap,
Firstly, thank you for posting a simple SMS working code. I was easily able to cross-check my code with it. Although everything seems almost the same, sending messages between emulators is not working currently..
In my project, i am trying to send SMS on click of a UI button. The second class (receiver) implements BroadcastReceiver to receive and reply to the sender. To test this, i am starting two emulator instances (5554 & 5556) of the same project from eclipse IDE manually.
Code snippet:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
sendBtn = (Button)findViewById(R.id.btnInvite);
sendBtn.setOnClickListener(new Button.OnClickListener() { public void onClick (View v){ Log.i("Click", "SendingReply"); sendInvite(); }});
}
public void sendInvite()
{
String sendData = "Invitation";
SmsManager mng = SmsManager.getDefault();
PendingIntent pi = PendingIntent.getBroadcast(this, 0, new Intent(), 0);
String addr = "5556";
if(addr == null)
{
Log.i("SmsIntent", "Unable to get Address from Sent Message");
}
try{
mng.sendTextMessage(addr, null, sendData, pi, pi);
}catch(Exception e){ Log.e("SmsIntent","SendException", e ); }
}
One observation:
When i launch a second instance of the emulator, the emulator displays the following errors on its UI:
Application Messaging(in process com.android.mms) is not responding
Application Alarm clock is not responding
When i force close them, it shows the UI with the single button (as in the main layout). Could this be a cause of the problem?
Is there any other better way of testing with two emulators? I also tested receiving message from a plain sms receiver which is an instance of some other project. Still no luck..
Kindly let me know..
Thanks in advance.