/**
* 判断应用是否已安装
*
* @param context
* @param packageName
* @return
*/
private
boolean
isInstalled(Context context, String packageName) {
hasInstalled =
false
;
PackageManager pm = context.getPackageManager();
List<PackageInfo> list = pm
.getInstalledPackages(PackageManager.PERMISSION_GRANTED);
for
(PackageInfo p : list) {
if
(packageName !=
null
&& packageName.equals(p.packageName)) {
true
break
}
return
hasInstalled;
* 获取文件安装的Intent
* @param file
Intent getFileIntent(File file) {
Uri uri = Uri.fromFile(file);
String type =
"application/vnd.android.package-archive"
Intent intent =
new
Intent(
"android.intent.action.VIEW"
);
intent.addCategory(
"android.intent.category.DEFAULT"
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setDataAndType(uri, type);
intent;
* 判断应用是否正在运行
isRunning(Context context, String packageName) {
ActivityManager am = (ActivityManager) context
.getSystemService(Context.ACTIVITY_SERVICE);
List<RunningAppProcessInfo> list = am.getRunningAppProcesses();
(RunningAppProcessInfo appProcess : list) {
String processName = appProcess.processName;
(processName !=
&& processName.equals(packageName)) {