【问题标题】:Android | Unmarshalling Unknown Type while using Parcelable Data vai Intent安卓 |使用 Parcelable Data vai Intent 时解组未知类型
【发布时间】:2016-02-25 07:33:18
【问题描述】:

我有两个活动 A 和 B 能够将数据从 A 发送到 B,但在 B 类中获得 android unmarshalling unknown type code

这是我的A班:

intent.putExtra("totalamount",total);

and in B im getting that value via
getIntent().getExtras("totalamount");

【问题讨论】:

  • 没有任何 getExtras(String) 方法。那应该是 getExtras().getString("totalamount") 或者适合totalamount类型的东西

标签: android unmarshalling


【解决方案1】:
 Bundle extras = getIntent().getExtras();
    if(extras != null) {
       extras.getFloat("totalamount"); // use the type of data in place of String
    }

【讨论】:

  • 我在 extras.getString("totalamount"); 时遇到运行时异常解组数据;
  • “totalamount”中的数据类型是什么。 ?我的意思是什么是总数??
【解决方案2】:

你必须像这样得到 Parcelable 对象:

Bundle extras = getIntent().getExtras();
if(extras != null) {
    extras.getParcelable("totalamount");
}

【讨论】:

    猜你喜欢
    • 2014-04-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-13
    • 1970-01-01
    • 2015-10-01
    • 2013-10-04
    • 1970-01-01
    相关资源
    最近更新 更多