0
私がバンドルエキストラデータで活動を開始するには、次のコードを使用
間でその値を失い、私は、データがテントエキストラで保存している見ることができます。バンドル活動
public static Intent newIntent(Context packageContext, AccountItem account, TransactionItem transaction) {
Bundle args = new Bundle();
args.putParcelable("arg_key_account", account);
args.putParcelable("arg_key_transaction", transaction);
args.putInt("test_key", 18);
Intent intent = new Intent(packageContext, TransactionConnectActivity.class);
intent.putExtra("arg_key", args);
intent.putExtra("test_key", 21);
return intent;
}
しかし、ときに私
protected void onCreate(@Nullable Bundle savedInstanceState) {
...
Intent intent = getIntent();
if (intent != null) {
int test = intent.getIntExtra("test_key", -1);
Bundle args = intent.getExtras().getBundle("arg_key");
}
...
}
0123:意図からバンドルエキストラデータを取得しようと、バンドルには、データを持ちません
カスタムオブジェクトにParcelable
が実装され、すべてのメンバーがパーセルに書き込まれています。私はこれらの質問と答えを読んだが、私はどこが間違っているのかまだ分かりません。
- Pendingintent getbroadcast lost parcelable data
- Parcelable object that receives passed data coming up null
- Parcelable custom object losing instance values when passed with intent
- Bundle loses values between activities
私は 'writeValue'を使用してStringメンバーをパースします。これは' writeString'を使用する必要があります。 – li2
あなた自身の質問に答えて、その答えを受け入れてください。これにより未回答の質問のリストから質問が削除されます。または、値がない場合は質問を削除してください。ありがとう。 –