我創建了一個包並將值放到它上面並跳到下一個活動,出於某種原因它無法在另一端獲取值,它說空對象的引用,但我有我的價值觀和我在一起,無法將值從一個活動發送到Android中的其他活動
public void rsa_key(String s){
Intent intent = new Intent(getBaseContext(), SomeClass.class);
//Create the bundle
Bundle bundle = new Bundle();
//Add your data to bundle
//String hello=null;
bundle.putString("id", txId);
bundle.putString("cardamt", cardAmount);
bundle.putString("cardconv", cardConvFee);
//Add the bundle to the intent
intent.putExtras(bundle);
startActivity(intent);
}
在其他活動
String txId = bundle.getString("id");
String cardConvFee = bundle.getString("cardconv");
String cardAmount = bundle.getString("cardamt");
你在哪裏有其他活動的代碼。在onCreate。另外使用調試器應該會有所幫助 – Raghunandan
你如何獲得第二項活動中的第一項活動?請張貼您的日誌。 –
我已經把它放在OnCreate之外,我猜這就是問題 – Venky