the following program is my sample program for Listening incoming sms.It is created .apk file
with out error but it does not display the message please help me.the toast does not display
any message if the emulator receive the message.
My scenario is receive the sms ansd display the alert dialog box to user.that sms contanins
email address depending on that address my app search the phone contacts and send the contact
number of the emailId's person as reply message
public void onReceive(Context context,Intent intent)
{
Bundle extras=intent.getExtras();
String messages="";
if(extras!=null)
{
Object[] smsExtra=(Object[]) extras.get("pdus");
for(int i=0;i<smsExtra.length;i++)
{
SmsMessage sms = SmsMessage.createFromPdu((byte[])smsExtra[i]);
String body = sms.getMessageBody().toString();
String address = sms.getOriginatingAddress();
messages += "SMS from " + address + " :\n";
messages += body + "\n";
}
Toast.makeText(context, messages, Toast.LENGTH_SHORT).show(); // not display
}
}//onReceive
my manifastfile
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="e.x.x"
android:versionCode="1"
android:versionName="0.1" >
<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.WRITE_SMS" />
<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<receiver android:name=".ex2" android:exported="true" >
<intent-filter android:priority="999" >
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
</manifest>