2014-03-31 112 views
0

我創建了一個應用程序,它使用GCM推送通知服務發送更新和通知。 以下是應用程序的鏈接Culrav 問題出在一些設備上,應用程序在第一次運行時崩潰,特別是在Kit-Kat上。在反饋報告中,我得到的錯誤是這樣的:廣播目的接收錯誤

java.lang.RuntimeException: Error receiving broadcast Intent 
act=mnnit.vinayakAj.culrav2k14.app.DISPLAY_MESSAGE flg=0x10 (has extras) } in 
[email protected] 
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) 

代碼爲廣播接收器是

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服務提供的代碼。 請幫我解決這個問題。

+0

把BroadcastReceiver代碼 –

回答

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. 
+0

我真的很抱歉,但我不明白你想說什麼。 我使用SDK版本19創建此應用程序,並且問題出現在4.0+設備上。 – user3479800