This commit is contained in:
wangcongtao
2020-06-09 14:36:09 +08:00
parent 8f20329b33
commit 61738bcf68
19 changed files with 194 additions and 114 deletions

View File

@@ -0,0 +1,29 @@
package com.mogo.utils;
import android.content.Context;
import android.content.Intent;
/**
* @author congtaowang
* @since 2020-02-03
* <p>
* 描述
*/
public class LaunchUtils {
/**
* 通过包名启动app
*
* @param context
* @param pkg 包名
*/
public static void launchByPkg( Context context, String pkg ) throws Exception {
Intent intent = getLaunchIntentForPackage( context, pkg );
intent.addFlags( Intent.FLAG_ACTIVITY_NEW_TASK );
context.startActivity( intent );
}
public static Intent getLaunchIntentForPackage( Context context, String pkg ) {
return context.getPackageManager().getLaunchIntentForPackage( pkg );
}
}