Intent跳转页面的几种方式
来源:互联网 发布:淘宝的优惠券是真的吗 编辑:程序博客网 时间:2024/06/05 16:37
Intent跳转页面的方式?
1,直接跳转
第一个参数是上下文:也就是从哪跳。
第二个参数是:跳到那。
Intent intent =new Intent(MainActivity.this,SecondActivity.class);
startActivity(intent);
2,匹配action和category条件才跳转。
从MainActivity跳转到SecondActivity,要匹配SecondActivity中的aciton和category两个标签。
(1)自定义action问题:
MainActivity中的内容:
Intent intent =new Intent("this_is_Intent_action_condition");
startActivity(intent);
Mainfest中的内容:
<activity android:name=".SecondActivity" >
<intent-filter>
<action android:name="this_is_Intent_action_condition" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
(2)自定义category问题:
Intent intent =new Intent("this_is_Intent_action_condition");
intent.addCategory("this_is_intent_category");
startActivity(intent);
Mainfest中的内容:
<activity android:name=".SecondActivity" >
<intent-filter>
<action android:name="this_is_Intent_action_condition" />
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="this_is_intent_category"/>
</intent-filter>
</activity>
注意:这句不能丢了,它是系统默认的。
<category android:name="android.intent.category.DEFAULT" />
Intent打开其他应用的方式?
匹配:
Intent.ACTION_VIEW是系统内置的。所以好多Activity,xml中Aciton标签都匹配。(因为是系统内置的,所以应用到的地方很多),匹配的会有很多,都有什么条件呢?
代码:
Intent intent =new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("http://www.baidu.com"));
startActivity(intent);
问题:自定义打开网址?匹配都有什么条件呢?
Condition:
1,Intent中传递的和action标签一致。
2,Intent中的setData和data标签类型要一致。
代码:
Intent intent =new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("http://www.baidu.com"));
startActivity(intent);
Mainfest中的内容:在activity 中添加action和数据的类型data,就可以匹配。
<activity android:name=".SecondActivity" >
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="http" />
</intent-filter>
</activity>
Intent中的data和xml中的data类型要一致。
问题:data中的标签类型都有哪些?
问题:自定义打开电话:(只需要下面代码)。Intent.ACTION_DIAL是系统提供的。
Intent intent =new Intent(Intent.ACTION_DIAL);
intent.setData(Uri.parse("tel:10010"));
startActivity(intent);
- Intent跳转页面的几种方式
- 页面跳转的几种方式
- JavaScript 页面跳转的几种方式
- 页面跳转的几种方式
- wml页面跳转的几种方式
- 页面跳转的几种方式
- js页面跳转的几种方式
- js页面跳转的几种方式
- PHP 页面跳转的几种方式
- JavaScript 页面跳转的几种方式
- 页面跳转的几种方式
- JavaScript 页面跳转的几种方式
- 跳转页面的几种常用方式
- 页面跳转的几种方式
- JavaScript 页面跳转的几种方式
- JavaScript 页面跳转的几种方式
- 页面跳转的几种方式
- jqurymobile跳转页面的几种方式
- 四元数,欧拉角和旋转矩阵之间的互相转换
- js 页面埋点
- [Leetcode] Edit Distance
- HTTP 协议详解
- 多线程-关键字Volatile
- Intent跳转页面的几种方式
- 总结一下今天在编程中遇到的问题和相应的解决办法
- Servlet
- 还是杂
- earlysuspend调用过程
- QT学习--connect使用详解
- 极光推送的经验总结
- js知识
- Android学习笔记(十六):include标签的使用