发送数据:

Bundle bundle = new Bundle();

bundle.putString("sex" , "男人");
bundle.putDouble("height" , 40,38);
 
Intent intent = new Intent();
intent.putExtras(bundle);
intent.setClass(ThisOne.this , ThatOne.class);
startActivity(intent);
 
接收数据:
Bundle bundle = this.getIntent().getExtras();
String sex = bundle.getString("sex");
double height = bundle.getDouble("height");

====================================
 
在Message中使用Bundle传递数据
 
Message msg = myHandler.obtainMessage();
Bundle b = new Bundle();
b.putInt("age" , 20);
b.putString("name" , "Jon");
msg.setData(b);
msg.sendToTarget();
 
class MyHandler extends Handler{
   public void handleMessage(Message msg){
      Bundle b = msg.getData();
      int age = b.getInt("age");
      String name = b.getString("name");
  }
}

Android Bundle的使用的更多相关文章

  1. android bundle存放数据详解

    转载自:android bundle存放数据详解 正如大家所知道,Activity之间传递数据,是将数据存放在Intent或者Bundle中 例如: 将数据存放倒Intent中传递: 将数据放到Bun ...

  2. 解决React Native unable to load script from assets index.android.bundle on windows

    React Native运行的时候,经常碰到React Native unable to load script from assets index.android.bundle on windows ...

  3. React Native: unable to load scripts from assets 'index.android.bundle' on real device

    问题:重新建了一个项目后,运行react-native run-android报: unable to load scripts from assets 'index.android.bundle' ...

  4. Unable to load script from assets 'index.android.bundle'.make sure you bundle is packaged correctly

    解决此问题 以下方法每次都需要执行命令2才能更新 1.创建assets目录 mkdir android/app/src/main/assets 2.执行命令 react-native bundle - ...

  5. 项目初始化以后出现:Unable to load script from assets 'index.android.bundle

    Mac中真机测试React Native project时出现Unable to load script from assets 'index.android.bundle' 2018年01月21日 ...

  6. react native中Unable to load script from assets 'index.android.bundle'解决方案

    刚刚朋友问我,说是创建好一个项目,运行后报错:Unable to load script from assets 'index.android.bundle',以前好好的没出现这种现象,于是我找到一个 ...

  7. Unable to load script from assets 'index.android.bundle' 出错?

    野路子太多,坑人真的!F**k 言归正传,当你运行 react native 程序的时候出现这个错误 ,如果您使用Windows,请按以下方式运行命令,或者如果出现错误“无法找到条目文件index.a ...

  8. React-Native 之 index.android.bundle

    问题: index.android.bundle  这个bug 我相信很少同学会遇到,然而就是这个问题,困扰了我跟我的同事多天, 各种方法处理:  进入 android 目录  ./gradlew c ...

  9. Android——Android Bundle详解(转)

    Android Bundle详解 1 Bundle介绍 Bundle主要用于传递数据:它保存的数据,是以key-value(键值对)的形式存在的. 我们经常使用Bundle在Activity之间传递数 ...

  10. Unable to load script from assets 'index.android.bundle'.Make sure your bundle is packaged correctly or you're running a packager server

    curl -k 'http://localhost:8081/index.android.bundle?platform=android' > android/app/src/main/asse ...

随机推荐

  1. 解决VS2012新建MVC3等项目时,收到加载程序集“NuGet.VisualStudio.Interop…”的错误

    vs2012来做一个mvc3的项目,哪知在创建ado数据模型时跳出这么一个东东 错 误: 此模板尝试加载组件程序集 “NuGet.VisualStudio.Interop, Version=1.0.0 ...

  2. C# 清楚Cookies

    //销毁Cookies中的数据 if (Request.Cookies["Ticket"] != null) { HttpCookie mycookie; mycookie = R ...

  3. NOSQL的应用,Redis/Mongo

    NOSQL的应用,Redis/Mongo 1.心路历程 上年11月份来公司了,和另外一个同事一起,做了公司一个移动项目的微信公众号,然后为了推广微信公众号,策划那边需要我们做一些活动,包括抽奖,投票. ...

  4. JPA学习---第三节:搭建JPA开发环境和全局事务介绍

    一.创建 Java 项目 1.导入所需的 jar 包: 2.创建 persistence.xml 文件, 代码如下: <?xml version="1.0" encoding ...

  5. Cocos2D创建项目

    创建项目 配置好开发环境后, 用CMD切换到~\cocos2d\cocos2d-x-2.2.2\tools\project-creator目录上执行以下脚本 python create_project ...

  6. execute、executeUpdate、executeQuery三者的区别(及返回值)

    1. ResultSet executeQuery(String sql); 执行SQL查询,并返回ResultSet 对象. 2.int executeUpdate(String sql); 可执行 ...

  7. [问题]C# 结构体对齐:如何将变长byte数组对齐

    [StructLayout(LayoutKind.Sequential,Pack=1)] struct Report_Read_Parameter { byte Confirmation; byte ...

  8. c++ 如何实现,readonly

    需求: 我要实现一个常量字段,只能赋值一次,赋值后不容许更改. 类似于c#的readonly或者java final #include <iostream> class  A{public ...

  9. [BZOJ 1044] [HAOI2008] 木棍分割 【二分 + DP】

    题目链接:BZOJ 1044 第一问是一个十分显然的二分,贪心Check(),很容易就能求出最小的最大长度 Len . 第二问求方案总数,使用 DP 求解. 使用前缀和,令 Sum[i] 为前 i 根 ...

  10. 国产神通数据库操作备忘(Linux)

    最近接触到国产神通数据库的一个项目,发现这个数据库还是挺有技术含量的,看起来做的还不错. 1.启动停止 在终端窗口中输入以下命令启动数据库: # /etc/init.d/oscardb_<数据库 ...