我是靠谱客的博主 留胡子饼干,这篇文章主要介绍Android 隐士跳转几种方式,现在分享给大家,希望可以做个参考。

1、只有 配置 action 进行跳转

复制代码
1
2
3
4
<intent-filter> <action android:name="testarouter"></action> <category android:name="android.intent.category.DEFAULT" /> </intent-filter>
复制代码
1
2
3
Intent intent = new Intent(); intent.setAction("testarouter"); startActivity(intent);

 

2、只附带 category 跳转

复制代码
1
2
3
4
5
<intent-filter> <action android:name="testarouter"></action> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.INFO" /> </intent-filter>
复制代码
1
2
3
4
5
Intent intent = new Intent(); intent.setAction("testarouter"); intent.addCategory(Intent.CATEGORY_DEFAULT); intent.addCategory(Intent.CATEGORY_INFO); startActivity(intent);

3、只附带 data 跳转

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//注:setData、setDataAndType、setType 这三种方法只能单独使用,不可共用 3.1、 <intent-filter> <action android:name="testarouter"></action> <category android:name="android.intent.category.DEFAULT" /> <data android:path="/testrpouter" android:scheme="x1" tools:ignore="AppLinkUrlError" /> </intent-filter> Intent intent = new Intent(); intent.setAction("testarouter"); Uri uri = Uri.parse("x1:/testarouter"); intent.setData(uri); startActivity(intent); 3.2、 <intent-filter> <action android:name="testarouter"></action> <category android:name="android.intent.category.DEFAULT" /> <data android:path="/testarouter" android:scheme="x1" android:mimeType="text/plain" tools:ignore="AppLinkUrlError" /> </intent-filter> Intent intent = new Intent(); intent.setAction("testarouter"); Uri uri = Uri.parse("x1:/testarouter"); intent.setDataAndType(uri, "text/plain"); startActivity(intent); 3.3、 <intent-filter> <action android:name="testarouter"></action> <category android:name="android.intent.category.DEFAULT" /> <data android:mimeType="text/plain" tools:ignore="AppLinkUrlError" /> </intent-filter> Intent intent = new Intent(); intent.setAction("testarouter"); intent.setType("text/plain"); startActivity(intent);

最后

以上就是留胡子饼干最近收集整理的关于Android 隐士跳转几种方式的全部内容,更多相关Android内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(78)

评论列表共有 0 条评论

立即
投稿
返回
顶部