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标签放在一起,放在一起会导致启动图标消失。
        至此就可以正常跳转了,当有满足条件的多个应用时会有一个选择窗口或者使用优先级,数值越大优先级越高。

版权声明:本文为qq_36390114原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。