I create an activity
<activity
android:name=".GetResponse"
android:label="@string/title_activity_main"
android:launchMode="singleTask">
<intent-filter>
<action android:name="ir.smspeik.sms.getresponse" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
that starts when a sms received. i write this code to
display sms but nothing is shown :
public class GetResponse extends Activity{
IntentFilter intentFilter;
private BroadcastReceiver intentReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
//---display the SMS received in the TextView---
//TextView SMSes = (TextView) findViewById(R.id.textView1);
Toast.makeText(context, intent.getExtras().getString("sms") +
"Ehsan",
Toast.LENGTH_SHORT).show();
String[] sms = intent.getExtras().getString("sms").split("-");
EditText smsNo = (EditText) findViewById(R.id.txtSmsNo);
smsNo.setText(sms[0]);
Toast.makeText(context,sms[0],
Toast.LENGTH_SHORT).show();
TextView smsBody = (TextView) findViewById(R.id.lblSmsBody);
smsBody.setText(sms[1]);
Toast.makeText(context,sms[1],Toast.LENGTH_SHORT).show();
}
};
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.getresponse);
intentFilter = new IntentFilter();
intentFilter.addAction("SMS_RECEIVED_ACTION");
//---register the receiver---
registerReceiver(intentReceiver, intentFilter);
}
}
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en