外部程序启动App

本文介绍了启动Android应用的三种常见方法:通过包名获取并启动、设置自定义Action触发启动以及使用Scheme进行深度链接。详细展示了每种方式的代码实现,并在AndroidManifest.xml中配置了相应的intent-filter。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

第一种:直接通过包名:

1

2

Intent LaunchIntent= getPackageManager().getLaunchIntentForPackage("com.joyodream.jiji");

                startActivity(LaunchIntent);

 

第二种:通过自定义的Action

1

2

3

4

5

6

7

8

Intent intent= new Intent();

                intent.setAction("com.joyodream.jiji.main");

                MainActivity.this.startActivity(intent);

<intent-filter>

                <action android:name="com.joyodream.jiji.main" />

                <category android:name="android.intent.category.DEFAULT" />               

            </intent-filter>

第三种:通过Scheme

1

2

3

4

5

6

7

8

9

10

11

Intent intent= new Intent();

                intent.setData(Uri.parse("joyodream://......"));

                startActivity(intent);

<intent-filter>

                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.DEFAULT" />

                <data android:scheme="joyodream" android:ssp="jiji" />               

            </intent-filter>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值