打开另外一个App

 

/**
	 * 打开一个app
	 * 
	 * @param packageName
	 * @param data
	 * @return
	 */
	public static boolean lanuchApp(Context context,String packageName, Bundle data) {
		try {
			Intent resolveIntent = context.getPackageManager().getLaunchIntentForPackage(packageName);
			if (resolveIntent == null) {
				PackageInfo p = context.getPackageManager().getPackageInfo(packageName, PackageManager.GET_ACTIVITIES);
				if (p != null) {
					resolveIntent = new Intent(packageName);
				}
			}
			if (resolveIntent != null) {
				if (data == null){
					data = new Bundle();
				}
				data.putBoolean("a", true);
				resolveIntent.putExtras(data);
				resolveIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
				context.startActivity(resolveIntent);
				return true;
			}
		} catch (Exception e) {
		}
		return false;
	}

  

 

posted @ 2016-06-19 18:25  wikiki  阅读(244)  评论(0编辑  收藏  举报