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

Android 一个app启动另一个app

2015-05-26 17:37 447 查看
第一个App中

[java] view
plaincopy





// 通过包名获取要跳转的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中

[java] view
plaincopy





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();

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: