当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要与传送时的参数一致。 

相关文章:

  • 2022-12-23
  • 2021-09-15
猜你喜欢
  • 2021-06-04
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-07
  • 2022-12-23
相关资源
相似解决方案