I'm creating at the moment a SMS Broadcast Receiver. I also use GoSMS in my phone.
The problems is: if i dont set android:priority
or set value less than 2147483647
(this is GoSms's priority)
for my receiver, i cannot receive the message.
When i set android:priority ="2147483647"
, my app can receive the message but, some application in my phone have been force close:
08-01 17:52:47.775: E/AndroidRuntime(3501): FATAL EXCEPTION: main
08-01 17:52:47.775: E/AndroidRuntime(3501): java.lang.RuntimeException: Unable to start service com.android.exchange.SmsRelayService@414f47f8 with Intent { cmp=com.android.exchange/.SmsRelayService (has extras) }: java.lang.NullPointerException
08-01 17:52:47.775: E/AndroidRuntime(3501): at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2388)
08-01 17:52:47.775: E/AndroidRuntime(3501): at android.app.ActivityThread.access$1900(ActivityThread.java:127)
08-01 17:52:47.775: E/AndroidRuntime(3501): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1222)
08-01 17:52:47.775: E/AndroidRuntime(3501): at android.os.Handler.dispatchMessage(Handler.java:99)
08-01 17:52:47.775: E/AndroidRuntime(3501): at android.os.Looper.loop(Looper.java:137)
08-01 17:52:47.775: E/AndroidRuntime(3501): at android.app.ActivityThread.main(ActivityThread.java:4507)
08-01 17:52:47.775: E/AndroidRuntime(3501): at java.lang.reflect.Method.invokeNative(Native Method)
08-01 17:52:47.775: E/AndroidRuntime(3501): at java.lang.reflect.Method.invoke(Method.java:511)
08-01 17:52:47.775: E/AndroidRuntime(3501): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
08-01 17:52:47.775: E/AndroidRuntime(3501): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
08-01 17:52:47.775: E/AndroidRuntime(3501): at dalvik.system.NativeStart.main(Native Method)
08-01 17:52:47.775: E/AndroidRuntime(3501): Caused by: java.lang.NullPointerException
08-01 17:52:47.775: E/AndroidRuntime(3501): at android.provider.Telephony$Sms$Intents.getMessagesFromIntent(Telephony.java:888)
08-01 17:52:47.775: E/AndroidRuntime(3501): at com.android.exchange.SmsRelayService.onStartCommand(SmsRelayService.java:69)
08-01 17:52:47.775: E/AndroidRuntime(3501): at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2371)
this is my code
public class SmsListener extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent) {
if(intent.getAction().equals(Constants.SMS_RECEIVED_ACTION)){
// Do some thing
}
}
}
and
<receiver android:name=".widget.SmsListener" >
<intent-filter android:priority="2147483647">
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
I am running in Galaxy S2, ICS
Help me please
Regards