Java 如何向android中的其他活动发送捆绑数组值?
如何向android中的其他活动发送捆绑数组值 我有一个classsun.java。它是生成bundle类型数组。我需要另一个activity中字符串格式的bundle类型数组 帮帮我 提前谢谢 Sun.java类`enterJava 如何向android中的其他活动发送捆绑数组值?,java,android,arrays,bundle,Java,Android,Arrays,Bundle,如何向android中的其他活动发送捆绑数组值 我有一个classsun.java。它是生成bundle类型数组。我需要另一个activity中字符串格式的bundle类型数组 帮帮我 提前谢谢 Sun.java类`enter Intent intent=new Intent(PaymentPageActvity.this,CancelPaymentActivity.class); Bundle b=new Bundle();
Intent intent=new Intent(PaymentPageActvity.this,CancelPaymentActivity.class);
Bundle b=new Bundle();
b.putBundle("inErrorMessage",inResponse);
Log.i("Error","onTransactionFailure :"+inErrorMessage);
Log.i("Error","onTransactionFailure :"+inResponse);
//intent.putExtras(inResponse);
//app.getLogger().error("Transaction Success :" + inResponse);
intent.putExtras(b);
startActivity(intent);
第二活性是
Bundle b=CancelPaymentActivity.this.getIntent().getExtras();
Bundle array=b.getBundle("inErrorMessage");
Log.i("array",""+array);
在logcat中,我得到了这个值
onTransactionFailure :Bundle[{INDUSTRY_TYPE_ID=Retail, payt_STATUS=1, ORDER_ID=FCF440, CHANNEL_ID=WAP, CUST_ID=48, ORDER_PHONE=7428453915, REQUEST_TYPE=DEFAULT, ORDER_EMAIL=singhamit1632@gmail.com, MID=klbGlV59135347348753, THEME=merchant, TXN_AMOUNT=8.0, WEBSITE=paytm, CHECKSUMHASH=PM5h/19blmHQyxBe2EDkMIi/Xqt5u3uijNMdWLJVzU60co6zhoHqmmFScNZaNVhwqrIm4kd2R6fEaROhFr9xsKtG96MIkymqkhtQ08DG6zQ=}]
你把它放在你开始活动的意图的额外部分。查看Intent类的Google文档您可以通过bundle对象发送string[]或ArrayList,如下所示
Bundle bundle=new Bundle();
bundle.putStringArray("STRING_ARRAY", yourStringArray);
bundle.putStringArrayList("STRING_ARRAY_LIST", stringArrayList);
Intent intent =new Intent(this, YourClass.class);
intent.putExtras(bundle);
希望这有帮助这是完整的日志吗?你得到了Bundle还是什么?那么Bundle的toString方法呢?