您的位置:首页 > 移动开发 > Android开发

Android 从一个应用跳转到另外一个应用

2017-07-26 10:29 435 查看

公司自主研发的项目。需要相互关联,资源共享,就需要应用的项目跳转,其实很简单,方法也有很多。

方法一:

try {
PackageManager packageManager = getPackageManager();
Intent intent= new Intent();
intent = packageManager.getLaunchIntentForPackage("自己项目的applicationId");
startActivity(intent);
} catch (Exception e) {
Toast.makeText(SystemUtil.getApplication(),"请到应用市场下载该应用",Toast.LENGTH_SHORT).show();
e.printStackTrace();
}

法法二:

自己项目的applicationId
com.cccollector.magazine.shoucangtouzidaokan.android
try {//com.cccollector.magazine.shoucangtouzidaokan.android
Intent intent = new Intent();
intent.setAction("com.cccollector.magazine"); //模糊跳转
intent.addCategory("shoucangtouzidaokan"); //精确跳转
startActivity(intent);
} catch (Exception e) {
//没有此应用
// Toast.makeText(this, "检查到您手机没有安装此应用,请安装后使用该功能", Toast.LENGTH_LONG).show();
//跳转到下载 pkgname就是applicationId
Intent it = new Intent(Intent.ACTION_VIEW, Uri.parse("http://a.app.qq.com/o/simple.jsp?pkgname=com.cccollector.magazine.shoucangtouzidaokan.android" ));
startActivity(it);
}清单文件配置

在启动的Activity里面配置如下参数。

<activity android:name=".MainActivity"
<!--对外的隐式跳转-->
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<!--对外的隐式跳转action category DEFAULT必须有-->
<action android:name="com.cccollector.magazine"/>
<category android:name="shoucangtouzidaokan"/>
</intent-filter>
</activity>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐