跳转其他app的三种方法

//需要跳转的app清单文件内
<activity
    android:name="com.xxx.xxx.xxx.MainActivity"
    android:configChanges="screenSize|keyboardHidden|orientation"
    android:screenOrientation="portrait">
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />

        <!--首页: baidu://zhidao/main -->
        <data
            android:host="zhidao"
            android:path="/main"
            android:scheme="baidu" />
    </intent-filter>
</activity>
//MainActivity.class内

@Override
protected void onNewIntent(Intent intent) {
    // TODO Auto-generated method stub
    setIntent(intent);
    super.onNewIntent(intent);
}

//跳转的地方

 Intent intent = getPackageManager().getLaunchIntentForPackage(aPKGStr);//只指定包名默认跳转首页

 
 Intent intent = new Intent(Intent.ACTION_MAIN);
 intent.setComponent(new ComponentName(aPKGStr, "com.xxx.xxx.xxx.MainActivity"));//指定包名,类名跳转指定页面
 intent.putExtra("index", 2);      

                

intent.setData(Uri.parse("baidu://zhidao/main"));//通过scheme协议跳转

猜你喜欢

转载自blog.csdn.net/csdnwr/article/details/53199191