public class MainActivity extends Activity {        final static int CANSHU = 1;            public Handler mHandler=new Handler(){          public void handleMessage(Message msg) {          switch(msg.what){              case CANSHU :   String str1 = msg.getData().getString("text1");//接受msg传递过来的参数                       String str2 = msg.getData().getString("text2");//接受msg传递过来的参数                       initFinishMainActivity(str1, str2);                                break;              default         : break;              }          }         };            @Override      public void onCreate(Bundle savedInstanceState) {          super.onCreate(savedInstanceState);          InitMainActivity();      }  
//Message使用bundle传递参数:     public void send() {                    Message msg = new Message();              msg.what = MainActivity.CANSHU;              Bundle bundle = new Bundle();                          bundle.putString("text1","大明的消息传递参数的例子!");  //往Bundle中存放数据                            bundle.putString("text2","Time:2016-11-03");  //往Bundle中put数据                            msg.setData(bundle);//mes利用Bundle传递数据                            activity.mHandler.sendMessage(msg);//用activity中的handler发送消息        }  
 

}

更多相关文章

  1. mybatisplus的坑 insert标签insert into select无参数问题的解决
  2. python起点网月票榜字体反爬案例
  3. Python技巧匿名函数、回调函数和高阶函数
  4. python list.sort()根据多个关键字排序的方法实现
  5. android http-post方法简单实现
  6. android工具详解
  7. 通过CMD 查看android APP数据库表
  8. android 上中文排序
  9. Android之SQLLite

随机推荐

  1. android: layout_alignParentRight androi
  2. Android之ScrollLayout左右滑动效果实现
  3. Android Context
  4. android 图片溢出问题2...[geoway]
  5. Android List divider显示不出来的问题
  6. Android中状态栏的隐藏
  7. Android 中OpenGL的使用
  8. Android开发--Intent-filter属性详解
  9. MAC环境Android(安卓)SDK环境变量配置201
  10. Android Animation 动画介绍与详解