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
/** | |
* 根据/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
/** | |
* 关闭软键盘 | |
* @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
要实现透明的Activity很简单,只需要给Activity设置一个透明的主题即可 | |
<activity | |
android:name="xxxxxxxx" | |
android:theme="@android:style/Theme.Translucent"> | |
<intent-filter> | |
<action android:name="android.intent.action.LAUCHER" /> | |
<category android:name="android.intent.category.DEFAULT" /> | |
</intent-filter> | |
</activity> |
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
package me.xiaopan.android.strogetest; | |
import android.os.Build; | |
import android.os.Environment; | |
import android.os.StatFs; | |
/** | |
* <h4>StatFs兼容类<h4/> | |
* | |
* 由于StatFs的API从API18之后发生了较大的变化,主要是Android官方认识到之前的API用起来不方便并且有坑,于是新添加了几个方法来替代旧的方法 |
OlderNewer