导入support-v4就可使用LocalBroadcasrManager,和普通的广播相比,LocalBroadcast的范围只是本应内,所以更有效率,更省资源
一个很方便用来处理url链接的工具类,之前开发过程中遇到需要处理支付宝网页url,获取里面post参数,当时使用String的各种接口进行处理,如果用UrlQuerySanitizer的话就简单多了。比如现在有个Url=http://example.com/?name=Mark
,我们使用UrlQuerySanitizer拿到name的值:
UrlQuerySanitizer sanitizer =newUrlQuerySanitizer(
"http://example.com/?name=Mark");
sanitizer.setAllowUnregisteredParamaters(true);
String name = sanitizer.getValue("name");
PhoneNumverUtils提供了一系列方法用来格式化电话号码
String num = "031185203009";
PhoneNumberUtils util = new PhoneNumberUtils();
String numFormated = util.formatNumber(num,"CN");
PackageManager public abstract int **checkSignatures** (String pkg1, String pkg2)
检查两个apk安装包的签名是否一样,一样的话返回值>0否则返回值<0
Comparethe signatures of two packages to determine if the same signature appears in both of them. If they do contain the same signature, then they are allowed special privileges when working with each other: they can share the same user-id, run instrumentation against each other, etc.
Parameters
pkg1:
First package name whose signature will be compared.
pkg2:
Second package name whose signature will be compared.
Returns
Returns an integer indicating whether all signatures on the two packages match. The value is >= 0 (SIGNATURE_MATCH) if all signatures match or < 0 if there is not a match (SIGNATURE_NO_MATCH or SIGNATURE_UNKNOWN_PACKAGE).
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/MainLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="@drawable/backrepeat"
>
backrepeat.xml
<bitmap
xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/repeatimg"
android:tileMode="repeat"
android:dither="true" />
可以很方便的创建视频的缩略图,甚至还可以指定缩略图的尺寸
// Create a video thumbnail for a video
static Bitmap createVideoThumbnail(String filePath, int kind)
//Creates a centered bitmap of the desired size.
static Bitmap extractThumbnail(Bitmap source, int width, int height,int options)
//Creates a centered bitmap of the desired size.
static Bitmap extractThumbnail(Bitmap source, int width, int height)
类型的HashMap专门写的类,目的是为了提供效率,其核心算法是折半查找。PackageManger public abstract void setComponentEnabledSetting (ComponentName componentName, int newState, int flags)
View public static int generateViewId ()
Generate a value suitable for use in setId(int). This value will not collide with ID values generated at build time by aapt for R.id.;
动态生成控件的福利啊,以后再也不用担心动态控件id冲突了。
ActivityManager public boolean clearApplicationUserData ()