30 lines
716 B
Java
30 lines
716 B
Java
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 );
|
|
}
|
|
}
|