我已创建了一个包并将值放到它上面并跳转到下一个活动,由于某种原因它无法在另一端获取值,它表示空对象引用,但我有我的值我,
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");
答案 0 :(得分:4)
试试这个:
public void rsa_key(String s){
Intent intent = new Intent(getBaseContext(), SomeClass.class);
//String hello=null;
intent.putExtras("id", txId);
intent.putExtras("cardamt", cardAmount);
intent.putExtras("cardconv", cardConvFee);
startActivity(intent);
}
在你的第二个活动onCreate方法
Bundle bundle = getIntent().getExtras();
String txId = bundle.getString("id");
String cardConvFee = bundle.getString("cardconv");
String cardAmount = bundle.getString("cardamt");
答案 1 :(得分:0)
请先在字符串中转换整数值,然后将其发送到另一个活动。
Bundle bundle = new Bundle();
//Add your data to bundle
//String hello=null;
bundle.putString("id", String.valueOf(txId));
bundle.putString("cardamt", String.valueOf(cardAmount));
bundle.putString("cardconv", String.valueOf(cardConvFee));