2012-06-07 89 views
0

當我得到從C2DM響應存在意圖對象 Req代碼中的錯誤:機器人C2DM註冊不成功的

意圖registrationIntent =新意圖(「com.google.android.c2dm.intent.REGISTER」); registrationIntent.putExtra(「app」,PendingIntent.getBroadcast(this,0,new Intent(),0)); registrationIntent.putExtra(「sender」,「[email protected]」);

,當我得到響應有一個錯誤:

public void onReceive(Context context, Intent intent) 
    { 

     if (intent.getStringExtra("error") == null) 
    { 
     System.out.println("Error in registration "); 
    } 
    } 

如果()條件爲真,爲什麼?

什麼是此錯誤的可能原因......

+0

我不認爲有一個錯誤,因爲跟它錯誤= null,並且不包含任何 – FabianCook

+0

當有在那個時候你會得到錯誤的參數值空在response.so而不是intent.getStringExtra沒有錯誤(「錯誤」)== null你可以把intent.getStringExtra(「error」)!= null –

回答

0

getStringExtra()文檔:

Returns the value of an item that previously added with putExtra() or null if no String value was found.

也許你要測試的字符串是否不爲空?

if (intent.getStringExtra("error") != null) { 
     System.out.println("Error in registration "); 
}