转载请注明出处:http://blog.csdn.net/guxiao1201/article/details/40707815
UrlQuerySanitizer
- 一个很方便用来处理url链接的工具类,之前开发过程中遇到需要处理支付宝网页url,获取里面post参数,当时使用String的各种接口进行处理,如果用UrlQuerySanitizer的话就简单多了。比如现在有个Url=http://example.com/?name=Mark,我们使用UrlQuerySanitizer拿到name的值:
UrlQuerySanitizer sanitizer = new UrlQuerySanitizer("http://example.com/?name=Mark");
sanitizer.setAllowUnregisteredParamaters(true);
String name = sanitizer.getValue("name");
Fragment public void setArguments (Bundle args)
- 在初始化Fragment时向Fragment传参的一个很方便的接口,在Fragment中使用getArguments()来接收。
Supply the construction arguments for this fragment. This can only be called before the fragment has been attached to its activity; that is, you should call it immediately after constructing the fragment. The arguments supplied here will be retained across fragment destroy and creation.
LocalBroadcastManager
- 导入support-v4就可使用LocalBroadcasrManager,和普通的广播相比,LocalBroadcast的范围只是本应内,所以更有效率,更省资源
PhoneNumberUtils public static String formatNumber (String phoneNumber, String defaultCountryIso)
- PhoneNumverUtils提供了一系列方法用来格式化电话号码
String num = "031185203009";
PhoneNumberUtils util = new PhoneNumberUtils();
String numFormated = util.formatNumber(num,"CN");
numFormated = 0311-8520-3009
Breaks the given number down and formats it according to the rules for the country the number is from.
Parameters
source | The phone number to format |
---|
Returns
- A locally acceptable formatting of the input, or the raw input if formatting rules aren't known for the number
Application public void registerActivityLifecycleCallbacks (Application.ActivityLifecycleCallbacks callback)
- 4.0以后新增的一个很方便的回调,callback中有一系列Activity生命周期的方法,例如OnActivityCreated、onActivityDestory和onActivityPaused等。可以在这些方法中一些统筹的逻辑功能,比如统计Activity的使用频率。
versionNameSuffix
- 在Gradle脚本中使用该标签可以修改在Manifest中定义的VersionName
Genymotion
- 一个比较好用的安卓模拟器,分为免费版、个人版和商业版,其中免费版提供了从2.3到4.4版本的SDK,并带有GPS和摄像头功能。我经常使用这个模拟器做博客Demo的gif图。免费版百度网盘链接:http://pan.baidu.com/s/1kTj2Nu3
Activity public void recreate ()
- 强制一个Activity重新创建自己一个新实例的方法,调用该方法目标Activity会重新走一遍自己的生命周期。
Cause this Activity to be recreated with a new instance. This results in essentially the same flow as when the Activity is created due to a configuration change -- the current instance will go through its lifecycle to onDestroy()
and a new instance then created after it.
PackageManager public abstract int checkSignatures (String pkg1, String pkg2)
- 检查两个apk安装包的签名是否一样,一样的话返回值>0否则返回值<0
Compare the 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
orSIGNATURE_UNKNOWN_PACKAGE
).
参考资料: