opt
This commit is contained in:
@@ -3,6 +3,9 @@ package com.mogo.utils;
|
||||
import android.app.ActivityManager;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -25,4 +28,22 @@ public class AppUtils {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isAppInstalled( Context context, String pkg ) {
|
||||
PackageInfo packageInfo;
|
||||
if ( TextUtils.isEmpty( pkg ) ) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
packageInfo = context.getPackageManager().getPackageInfo( pkg, 0 );
|
||||
} catch ( PackageManager.NameNotFoundException e ) {
|
||||
packageInfo = null;
|
||||
e.printStackTrace();
|
||||
}
|
||||
if ( packageInfo == null ) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user