Android 一个app启动另一个app
2015-05-22 22:48 阅读(177)

[支付宝钱包],可以从支付宝直接跳转到[去啊],如果没有按照还提醒用户是否安装,有点炫酷哦,去啊的用户量一下增多了


第一个App中

// 通过包名获取要跳转的app,创建intent对象
Intent intent = activity().getPackageManager()
    .getLaunchIntentForPackage("com.zsl.download");// 这里如果intent为空,就说名没有安装要跳转的应用嘛
if (intent != null) {// 这里跟Activity传递参数一样的嘛,不要担心怎么传递参数,还有接收参数也是跟Activity和Activity传参数一样
    intent.putExtra("name", "郑松岚");
    startActivity(intent);
} else { // 没有安装要跳转的app应用,提醒一下
    ToastUtils.showLongToast(activity(), "没安装此APP");
 }


第二个App中

Intent intent = getIntent();
Bundle bundle = intent.getExtras();       
if (bundle != null) {
    String name = bundle.getString("name");           
    if (name != null) {
        Toast.makeText(getApplicationContext(), "name:" + name, Toast.LENGTH_SHORT).show();
    }
}