I have tried many (if not all...) Receive SMS examples, but it always failed before even onReceive() is called.
The CatLog:
10-26 20:05:30.990: INFO/System.out(2714): INFO: Received message
10-26 20:05:30.998: INFO/System.out(2714): INFO: Message body: Lmjgk
10-26 20:05:31.021: WARN/ActivityManager(1317): Unable to launch app org.apache.sms/10166 for broadcast Intent { act=android.provider.Telephony.SMS_RECEIVED (has extras) }: process is bad
10-26 20:05:31.021: WARN/ActivityManager(1317): finishReceiver called but none active
When implemented alongside another BroadcastReceiver android.intent.action.PHONE_STATE, the later is being called and was working perfectly well while the SMS failed.
To simplify it I just created the hello example and updates to the manifest and one file for the SMS BroadcastReceiver.
The manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.byp.sms" android:versionCode="1" android:versionName="1.0">
<uses-sdk android:minSdkVersion="9" />
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".HelloActivity" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name="com.byp.sms.SMSReceiver">
<intent-filter>
<action android:name="android.provider.telephony.SMS_RECEIVED"></action>
</intent-filter>
</receiver>
</application>
<uses-permission android:name="android.permission.RECEIVE_SMS"></uses-permission>
<uses-permission android:name="android.permission.READ_SMS" />
</manifest>
The BroadcastReceiver
package com.byp.sms;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
public class SMSReceiver extends BroadcastReceiver {
private static final String ACTION = "android.provider.Telephony.SMS_RECEIVED";
@Override
public void onReceive(Context context, Intent intent) {
Log.d("SMSReceiver", "onReceive"); // <<=== It does not even get here....
if (intent != null && intent.getAction() != null
&& ACTION.compareToIgnoreCase(intent.getAction()) == 0) {
Object[] pduArray = (Object[]) intent.getExtras().get("pdus");
Log.d("SMSReceiver", "SMSReceived " + pduArray.toString());
}
Log.d("SMSReceiver", "onReceive...Done");
}
}
Hello Activity: No changes to the generated code
package com.byp.sms;
import android.app.Activity;
import android.os.Bundle;
public class HelloActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
It did not help that I cleaned up all related apps from the device, uninstalled it, rebooted the device, etc, etc.
Any advice or a tip will be greatly appreciated!
Thanks