Android跨进程唤醒APP,启动指定页面

1 自定义启动协议。

AndroidManifest.xml中配置通过唤起启动的页面。

        
        <activity android:name=".SecondActivity"
            android:screenOrientation="portrait"
            android:theme="@style/ThemeSplash"
            android:alwaysRetainTaskState="true"
            android:launchMode="singleTask"
            android:noHistory="true">
            <intent-filter android:autoVerify="true">
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                
                <data android:scheme="wapchief" />
            intent-filter>
        activity>
2 Activity中获取其它进程传递的Data数据
Intent intent = getIntent();
Uri deeplink = intent.getData();
String result = deeplink.toString();
3 正则匹配要跳转的界面

    /**登录*/
    public static final Pattern IS_LOGIN = Pattern.compile("wapcheif://login+");
    /**注册*/
    public static final Pattern IS_REGISTER = Pattern.compile("wapcheif://register+");

        if (IS_LOGIN.matcher(result).find()) {
            intent = new Intent(context, LoginActivity.class);
            context.startActivity(intent);

        }else if (IS_REGISTER.matcher(result).find()) {
            intent = new Intent(context, RegisterActivity.class);
            context.startActivity(intent);

        }
4 在调用方APP使用指定协议跳转
        mButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent action = new Intent(Intent.ACTION_VIEW, Uri.parse("wapcheif://register"));
                startActivity(action);
            }
        });

你可能感兴趣的:(android)