Android 判断File是否为apk文件
public static Boolean isApkFile(Context context, String filePath) {
String pkg;
try {
PackageManager packageManager = context.getPackageManager();
PackageInfo info = packageManager.getPackageArchiveInfo(filePath, PackageManager.GET_ACTIVITIES);
if (info !=null) {
ApplicationInfo appInfo = info.applicationInfo;
pkg=appInfo.packageName;//得到安装包名称
}else{
pkg="";
}
}catch (Exception e) {
pkg="";
}
return !TextUtils.isEmpty(pkg);
}