当Activity与Activity/Service(或其它情况)有时与要进行参数传递,最常用也是最简单的方式就是通过Intent来处理。
看如下代码:
Intent intent = new Intent(...);Bundle bundle = new Bundle();bundle.putString("NAME", "zixuan");intent.putExtras(bundle);context.startActivity(intent); 或 context.startService(intent);
当然,有传送就有接收,接收也很简单,如:
Bundle bunde = intent.getExtras();String name = bunde.getInt("NAME");
当然参数KEY要与传送时的参数一致。
(作者:子轩,邮箱:[email protected])
[本节结束]
1 楼 东方胜 2012-07-10
