version:1.7
fix: update:修改布局,爱心守护播放视频,
This commit is contained in:
@@ -11,7 +11,9 @@ import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.uiui.os.BuildConfig;
|
||||
import com.uiui.os.bean.DesktopIcon;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.Collator;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
@@ -91,7 +93,11 @@ public class APKUtils {
|
||||
return applicationInfos;
|
||||
}
|
||||
|
||||
public static ArrayList<ApplicationInfo> queryFilterAppInfo(Context context) {
|
||||
/**
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
public static ArrayList<DesktopIcon> queryFilterAppInfo(Context context) {
|
||||
PackageManager pm = context.getPackageManager();
|
||||
// 查询所有已经安装的应用程序
|
||||
List<ApplicationInfo> appInfos = pm.getInstalledApplications(PackageManager.GET_UNINSTALLED_PACKAGES);// GET_UNINSTALLED_PACKAGES代表已删除,但还有安装目录的
|
||||
@@ -142,7 +148,11 @@ public class APKUtils {
|
||||
}
|
||||
}
|
||||
});
|
||||
return applicationInfos;
|
||||
ArrayList<DesktopIcon> desktopIcons = new ArrayList<>();
|
||||
for (int p = 0; p < applicationInfos.size(); p++) {
|
||||
desktopIcons.add(DesktopIcon.creatDesktopIcon(context, applicationInfos.get(p), p));
|
||||
}
|
||||
return desktopIcons;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -200,6 +210,32 @@ public class APKUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean openPackage(Context context, String packageName) {
|
||||
Context pkgContext = getPackageContext(context, packageName);
|
||||
Intent intent = getAppOpenIntentByPackageName(context, packageName);
|
||||
if (pkgContext != null && intent != null) {
|
||||
pkgContext.startActivity(intent);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static Context getPackageContext(Context context, String packageName) {
|
||||
Context pkgContext = null;
|
||||
if (context.getPackageName().equals(packageName)) {
|
||||
pkgContext = context;
|
||||
} else {
|
||||
// 创建第三方应用的上下文环境
|
||||
try {
|
||||
pkgContext = context.createPackageContext(packageName,
|
||||
Context.CONTEXT_IGNORE_SECURITY
|
||||
| Context.CONTEXT_INCLUDE_CODE);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return pkgContext;
|
||||
}
|
||||
|
||||
public static Intent getAppOpenIntentByPackageName(Context context, String packageName) {
|
||||
//Activity完整名
|
||||
@@ -226,33 +262,6 @@ public class APKUtils {
|
||||
return intent;
|
||||
}
|
||||
|
||||
public static Context getPackageContext(Context context, String packageName) {
|
||||
Context pkgContext = null;
|
||||
if (context.getPackageName().equals(packageName)) {
|
||||
pkgContext = context;
|
||||
} else {
|
||||
// 创建第三方应用的上下文环境
|
||||
try {
|
||||
pkgContext = context.createPackageContext(packageName,
|
||||
Context.CONTEXT_IGNORE_SECURITY
|
||||
| Context.CONTEXT_INCLUDE_CODE);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return pkgContext;
|
||||
}
|
||||
|
||||
public static boolean openPackage(Context context, String packageName) {
|
||||
Context pkgContext = getPackageContext(context, packageName);
|
||||
Intent intent = getAppOpenIntentByPackageName(context, packageName);
|
||||
if (pkgContext != null && intent != null) {
|
||||
pkgContext.startActivity(intent);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static String getAPPVersionName(Context context, String packageName) {
|
||||
String versionName = "0";
|
||||
|
||||
@@ -280,4 +289,40 @@ public class APKUtils {
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 检查手机上是否安装了指定的软件
|
||||
*/
|
||||
public static boolean isAvailable(Context context, String packageName) {
|
||||
PackageManager packageManager = context.getPackageManager();
|
||||
PackageInfo info = null;
|
||||
try {
|
||||
info = packageManager.getPackageInfo(packageName, 0);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return info != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查手机上是否安装了指定的软件
|
||||
*/
|
||||
public static boolean isAvailable(Context context, File file) {
|
||||
return isAvailable(context, getPackageName(context, file.getAbsolutePath()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据文件路径获取包名
|
||||
*/
|
||||
public static String getPackageName(Context context, String filePath) {
|
||||
PackageManager packageManager = context.getPackageManager();
|
||||
PackageInfo info = packageManager.getPackageArchiveInfo(filePath, PackageManager.GET_ACTIVITIES);
|
||||
if (info != null) {
|
||||
ApplicationInfo appInfo = info.applicationInfo;
|
||||
return appInfo.packageName; //得到安装包名称
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user