广播意图收到错误

时间:2014-03-31 05:25:20

标签: android broadcastreceiver google-cloud-messaging

我创建了一个使用GCM推送通知服务发送更新和通知的应用。 这是应用Culrav的链接 问题在于某些设备,应用程序在首次运行时崩溃,特别是在Kit-Kat上。在反馈报告中,我得到的错误是:

java.lang.RuntimeException: Error receiving broadcast Intent
act=mnnit.vinayakAj.culrav2k14.app.DISPLAY_MESSAGE flg=0x10 (has extras) } in 
mnnit.vinayakAj.culrav2k14.q@41c61758
at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:765)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4744)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalArgumentException: Null parameters are not accepted
at a.a.a.a.a.d.<init>(Unknown Source)
at a.a.a.a.a.d.a(Unknown Source)
at mnnit.vinayakAj.culrav2k14.q.onReceive(Unknown Source)
at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:755)

BroadcastReceiver的代码是

private final BroadcastReceiver mHandleMessageReceiver = new BroadcastReceiver() {
    @Override
    public void onReceive(Context context, Intent intent) {
        String newMessage = intent.getExtras().getString("MESSAGE");
        Crouton.makeText(getParent(), newMessage, Style.INFO).show();
    }
};

我正在关注AirBop GCM-Server服务提供的代码。 请帮我解决这个问题。

1 个答案:

答案 0 :(得分:0)

Bcoz of your SDK tools are maybe Upgrade version doesnt support.. for example you create your project in SDK min level is 8 but your android SDk version tools is APK level 19 means it may occurs so go to your SDk Folder and delete tools Folder and then Copy your cuurent version of SDk tools must be put it in your SDK Folder.
you are using low level APK version means it will generate this line bcoz you want to access high high level code in Upgrade version supported methods means this lines will shows of your methods..

@SuppressLint("NewApi")
@Override
public void onCreate(Bundle savedInstanceState) {

and also set this line in your activity

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
            int shortAnimTime = getResources().getInteger(
                    android.R.integer.config_shortAnimTime);
or 
if (android.os.Build.VERSION.SDK_INT > 9) {
        StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
        StrictMode.setThreadPolicy(policy);
    }

Ref Below link: for Broadcast Receiver.

http://developer.android.com/guide/components/services.html
-----------------------------------------------------------

'startService(i1);'//Start Service.
Use startActivityForResult() instead of startActivity() bcoz in service we use 'startActivityResult()'
method bcoz broadcast receiver will give the response of onresultActivity.. so you could use this line

Use 'startActivityForResult(intent,requestcode)' instead of 'startActivity()'.

thank you.