Intent隐式跳转应用(开发设置权限管理界面)

1.Intent跳转应用有显式和隐式区分
显式跳转就是

Intent intent = new Intent(classA.this, classB.class);
startActivity(intent);

隐式跳转有三种
(1.)Intent mSettingsIntent = new Intent(Intent.ACTION_MAIN) .setAction(Settings.ACTION_MANAGE_OVERLAY_PERMISSION); startActivity(mSettingsIntent);
捕捉到的action
(2)Intent intent = new Intent();
intent.setAction(MY_ACTION);
startActivity(intent);
Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION);
Uri uri = Uri.fromParts(“package”, getPackageName(), null);
intent.setData(uri);
startActivity(intent);
捕捉到的actin
(3)startActivityForResult(new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS, Uri.parse(“package:” + “com.example.selfdesigncomponent”)), 0);
捕捉到的action
这是启动方需要做的处理当他找到符合条件的应用就会去启动,找不到时就会闪退。
2.接收方需要做的处理

 <activity
            android:name=".Activity"
            android:launchMode="singleTop"
           
            <intent-filter android:priority="1000">
                <action android:name="android.intent.action.MAIN" />
                <action android:name="android.intent.action.VIEW" />
                <action android:name="android.settings.SETTINGS" />
                <action android:name="com.android.net.wifi.SETUP_WIFI_NETWORK" />
                <action android:name="android.settings.SECURITY_SETTINGS"/>
                <action android:name="android.settings.WIRELESS_SETTINGS" />
                <action android:name="android.horion.HOTSPOT_SETTINGS" />
                <action android:name="com.android.net.wifi.CANVAS_SETUP_WIFI_NETWORK" />
                <action android:name="android.settings.ACTION_PRINT_SETTINGS"/>
                <action android:name="android.settings.MANAGE_UNKNOWN_APP_SOURCES" />

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

            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.DEFAULT" />

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

                <action android:name="android.settings.action.MANAGE_OVERLAY_PERMISSION" />

                <action android:name="android.settings.APPLICATION_DETAILS_SETTINGS" />

                <data android:scheme="package" />
            </intent-filter>
        </activity>

主要的处理代码是`

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

            <action android:name="android.settings.action.MANAGE_OVERLAY_PERMISSION" />

            <action android:name="android.settings.APPLICATION_DETAILS_SETTINGS" />

            <data android:scheme="package" />
        </intent-filter>`
        action是对应的action data是接受发送方携带的包名等数据,
        注意action.default必须有。以及data标签不可以和launcher标签放在一起,放在一起会导致启动图标消失。
        至此就可以正常跳转了,当有满足条件的多个应用时会有一个选择窗口或者使用优先级,数值越大优先级越高。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值