-
数据传递
-
传递给Activity
-
startActivity()
-
startActivityForResult()
-
-
传递给Service
-
startService()
-
startServiceForResult()
-
-
传递给Broadcast
-
sendBroadcast()
-
sendOrderedBroadcast()
-
Context.sendStickyBroadcast()
-
-
-
指定跳转
-
指定目标组件名称: intent.setComponent(new ComponentName(“目标组件所在应用包名”, “目标组件的全限定名”));
-
指定目标组件的class类名: intent.setClass(this, 目标组件类名.class);
-
构造Intent:Intent intent = new Intent(当前组件类名.class,目标组件类名.class);
-
指定目标组件的class类名setClassName(MainActivity.this,“目标组件的全限定名.class”);
-
intent.setAction(“自定义action”);目标组件配置action标签在AndroidManifest.xml中来响应动作.
-
-
标准Activity动作
-
ACTION _MAIN:作为初始Activity启动,没有数据输入/输出
-
ACTION _VEIW:将数据显示给用户
-
ACTION _ATTACH_DATA:用于指示一些数据应附属于其他地方
-
-
Intent发送
-
putExtra()
-
通过bundle
-
bundle.putString
-
intent.putExtras(bundle)
-
-
message中bundle
-
bundle = new Bundle()
-
bundle.putString
-
message.setData(bundle)
-
-
-
Intent接收
-
getIntent()
-
getIntExtra()
-
通过bundle
-
bundle = intent.getExtras()
-
bundle.getInt()
-
-
message中bundle
-
msg.getData()
-
bundle.getInt()
-
-
-
Intent
最新推荐文章于 2023-08-10 17:19:07 发布