Hi,
I would apprecite you help here if you can.
I have written a simple sms application and I want to be able to display a new screen to the user when ever a new SMS arrives. I would like to do this using an Intent
Here is the code. The problem is with the Intent within Broadcastreceive. The error is
The constructor Intent(mySMSResult, Class<showresult>) is undefined
Any ideas
Thanks
Graham
}
I would apprecite you help here if you can.
I have written a simple sms application and I want to be able to display a new screen to the user when ever a new SMS arrives. I would like to do this using an Intent
Here is the code. The problem is with the Intent within Broadcastreceive. The error is
The constructor Intent(mySMSResult, Class<showresult>) is undefined
Any ideas
Thanks
Graham
import
android.os.Bundle;
import
android.telephony.SmsMessage;
import
android.widget.Toast;
import
android.content.BroadcastReceiver;
import
android.content.Context;
import
android.content.Intent;
public
class mySMSResult extends BroadcastReceiver {
public static final String SMSRECEIVED = "SMSR";
private static final String SMS_REC_ACTION = "android.provider.Telephony.SMS_RECEIVED";
@Override
public static final String SMSRECEIVED = "SMSR";
private static final String SMS_REC_ACTION = "android.provider.Telephony.SMS_RECEIVED";
@Override
public void onReceive(final Context context, final Intent intent) {
if (intent.getAction().equals(mySMSResult.SMS_REC_ACTION)) {
StringBuilder sb = new StringBuilder();
Bundle bundle = intent.getExtras();
if (bundle != null) {
Object[] pdus = (Object[]) bundle.get("pdus");
for (Object pdu : pdus) {
SmsMessage smsMessage = SmsMessage.createFromPdu((byte[]) pdu);
sb.append("body - " + smsMessage.getDisplayMessageBody() + "header -" + smsMessage.getProtocolIdentifier());
}
}
if (intent.getAction().equals(mySMSResult.SMS_REC_ACTION)) {
StringBuilder sb = new StringBuilder();
Bundle bundle = intent.getExtras();
if (bundle != null) {
Object[] pdus = (Object[]) bundle.get("pdus");
for (Object pdu : pdus) {
SmsMessage smsMessage = SmsMessage.createFromPdu((byte[]) pdu);
sb.append("body - " + smsMessage.getDisplayMessageBody() + "header -" + smsMessage.getProtocolIdentifier());
}
}
Intent i =
new Intent(mySMSResult.this, showresult.class);
startActivity(i);
}
}
startActivity(i);
}
}
}