public void parseApk(Context context, String apkFilePath){
PackageManager packageManager = context.getPackageManager();
PackageInfo packageInfo = packageManager.getPackageArchiveInfo(apkFilePath, 0);
if(packageInfo != null){
packageInfo.applicationInfo.sourceDir = apkFilePath;
packageInfo.applicationInfo.publicSourceDir = apkFilePath;
String name = packageInfo.applicationInfo.loadLabel(packageManager).toString();
String packageName = packageInfo.packageName;
String versionName = packageInfo.versionName;
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package me.xiaopan.java.util; | |
import java.text.ParseException; | |
import java.text.SimpleDateFormat; | |
import java.util.Calendar; | |
import java.util.Date; | |
import java.util.GregorianCalendar; | |
import java.util.Locale; | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public String getAndroidId() { | |
return Secure.getString(MApplication.getAppContext().getContentResolver(), Secure.ANDROID_ID); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 关闭软键盘 | |
* @param activity | |
*/ | |
public static void closeSoftInput(Activity activity){ | |
InputMethodManager methodManager = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE); | |
methodManager.hideSoftInputFromWindow(activity.getWindow().getDecorView().getWindowToken(), 0); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.lang.reflect.Field; | |
import android.content.Context; | |
import android.graphics.Color; | |
import android.util.Log; | |
import android.view.Gravity; | |
import android.view.View; | |
import android.view.View.OnClickListener; | |
import android.view.ViewGroup; | |
import android.widget.AbsListView; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PackageManager packageManager = context.getPackageManager(); | |
List<PackageInfo> packageInfos = packageManager.getInstalledPackages(0); | |
for(PackageInfo packageInfo : packageInfos){ | |
if((ApplicationInfo.FLAG_SYSTEM&packageInfo.applicationInfo.flags) != 0){ | |
Log.w("应用", packageInfo.packageName+" "+packageInfo.applicationInfo.loadLabel(packageManager)+" 系统应用"); | |
}else{ | |
Log.d("应用", packageInfo.packageName+" "+packageInfo.applicationInfo.loadLabel(packageManager)+" 用户应用"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PackageManager packageManager = context.getPackageManager(); | |
List<PackageInfo> packageInfos = packageManager.getInstalledPackages(0); | |
for(PackageInfo packageInfo : packageInfos){ | |
Log.w("应用", packageInfo.applicationInfo.loadLabel(packageManager)+" 包名:"+packageInfo.packageName+" 安装包位置:"+packageInfo.applicationInfo.publicSourceDir); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package me.xiaopan.android.strogetest; | |
import android.annotation.TargetApi; | |
import android.content.Context; | |
import android.os.Build; | |
import android.os.Environment; | |
import android.os.storage.StorageManager; | |
import android.util.Log; | |
import java.lang.reflect.InvocationTargetException; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 根据/system/bin/或/system/xbin目录下是否存在su文件判断是否已ROOT | |
* @return | |
*/ | |
public static boolean isRoot() { | |
try { | |
return new File("/system/bin/su").exists() || new File("/system/xbin/su").exists(); | |
} catch (Exception e) { | |
return false; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.json.JSONArray; | |
import org.json.JSONException; | |
import org.json.JSONObject; | |
import java.util.Iterator; | |
/** | |
* 一个简单的JSON字符串格式化工具 | |
*/ | |
public class JsonFormatter { |
OlderNewer