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

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

方法一:


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>



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值