我想從sendBroadcast收到string[][]
,但失敗。 第一,我成立了一個sendBroadcast:如何從sendBroadcast接收字符串[] []
Intent intent = new Intent("json_info");
intent.putExtra("routeshout", result);
sendBroadcast(intent);
其中結果是string[][]
有:
@Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
String[][] str_result = intent.getStringArrayExtra("routeshout");
result.setText(str_result[0]);
Log.d(TAG,"onReceive: "+str_result[1]);
}
};
,但我可以通過應用String[][] str_result = intent.getStringArrayExtra("routeshout");
任何建議得到string[][]
???
它可以正常工作「Bundle extras = intent.getExtras();」 但是當「String [] [] str_result =(String [] [])extras.get(」routeshout「);」我得到了關機和「03-26 04:53:04.490:E/AndroidRuntime(4460):致命的例外:主 」 – Hao 2012-03-26 04:54:14
@浩這就是我說的情況;如果你想要一個複雜的類型通過你的bundle,那麼它需要擴展Serializable或Parcelable,這取決於所需的效率和控制級別。該平臺爲您提供了某些簡單類型(字符串數組,值類型等)的這種功能 – 2012-03-26 14:45:05