• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

SMS help with broadcastreceiver startintent

gbwien

Lurker
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
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 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());

}
}

Intent i =​
new Intent(mySMSResult.this, showresult.class);
startActivity(i);

}
}

}
 
Either it can't find your showresults class because it is not typed right. Maybe the 's' is capilatized or something. Or you did not update the manifest to allow for the proper intent filters.

Without the whole project, and just that one class that is all I can suggest to you.

-Evan
 
Back
Top Bottom