如何使用意向和意向过滤器将任何消息从一项活动发送到另一项。意图和意图过滤器
Q
意图和意图过滤器
-2
A
回答
2
使用意向
Bundle extras = new Bundle();
extras.putString("my.unique.extras.key", "this is my message");
myIntent.putExtras(extras);
的putExtras(Bundle)方法然后在Intent您检索的额外
Bundle extras = this.getIntent().getExtras();
if (extras != null) {
if (extras.containsKey("my.unique.extras.key")) {
this.setTitle(extras.getString("my.unique.extras.key"));
}
}
这是一个duplicate question。
0
安意图可以包含数据。这些数据可以被接收组件使用。有两种类型的意向
明确意图
隐性意图
,并告知系统隐含的意图,他们可以处理,活动,服务和广播接收机可以有一个或多个意图过滤器。 有下意向滤波器三个测试这些是
动作试验
类别测试
数据测试
类从一个发送消息活动另一个使用意图和意图过滤器
public class MessageActivity extends Activity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.message); Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse("sms:")); startActivity(i); }}
XML代码
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <TextView android:layout_width="match_parent" android:layout_height="wrap_content"/> </LinearLayout>
这里我们使用隐式意图,所以我们必须在赋予权限的AndroidManifest.xml文件
<uses-permission android:name="android.permission.MESSAGE" />
和注册Message类内部应用
<activity android:name=".MessageActivity" >
<intent-filter>
<action android:name="android.intent.action.MESSAGE" /> </intent-filter>
</activity>
相关问题
- 1. Android意图和意图过滤器
- 2. Android意图过滤器
- 3. Android - 意图过滤器?
- 4. Android梁意图过滤器
- 5. 错误:意图过滤器
- 6. 相机意图过滤器
- 7. 广播和意图过滤
- 8. Passthrough意图过滤器和活动
- 9. 意图过滤pathPrefix
- 10. 意图过滤器/意图的发件人,android
- 11. 意图对象不触发意图过滤器
- 12. 以明确的意图使用意图过滤器
- 13. 意图过滤器捕捉意图查看* .EXT文件
- 14. Android意图过滤优先
- 15. 分享意图过滤
- 16. 得到意图过滤
- 17. Android的意图过滤pathPattern
- 18. 安卓:在意图过滤
- 19. 如何获得意图过滤器MimeType
- 20. 没有意图过滤器的Android BroadcastReceiver
- 21. ActivityNotFoundException - 意图过滤器不再工作
- 22. Android上的意图过滤器
- 23. 带有意图过滤器的Webview
- 24. Android意图过滤器笔记
- 25. 意图过滤器的android:pathPrefix url参数
- 26. 意图过滤器的路径模式
- 27. android的意图过滤器下载
- 28. Android意图过滤器问题
- 29. 设置活动的意图过滤器
- 30. 找到正确的意图过滤器
您是否听说过www.google.com和developer.android.com? – Siddharth 2013-05-23 03:00:49