1. setRequestedOrientation(1);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
2.mWebView.setScrollBarStyle(0);
setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY)
3.webSettings.setCacheMode(int);
public static final int LOAD_DEFAULT= -1;
public static final int LOAD_NORMAL =0;
public static final int LOAD_CACHE_ELSE_NETWORK =1;
public static final int LOAD_NO_CACHE =2;
public static final int LOAD_CACHE_ONLY =3;
webSettings.setCacheMode(int);
4.setVisibility(int)
publicstaticfinalintVISIBLE =0;
publicstaticfinalintINVISIBLE =4;
publicstaticfinalintGONE =8;
则对于:setVisibility(0) ==> setVisibility(View.VISIBLE)
其他依次类推。
5.calendar.set(int field, int value)
calendar.get(int)
Calendar这是一个日期工具类,也是根据当前常量获取返回的显示格式时间
get以及set就是获取下面的具体常量
field参数代表需要传入的常量 value就是需要换算的时间值
public final static int YEAR =1;
public final static int MONTH =2;
public final static int WEEK_OF_YEAR =3;
public final static int WEEK_OF_MONTH =4;
public final static int DATE =5;
public final static int DAY_OF_MONTH =5;
public final static int DAY_OF_YEAR =6;
public final static int DAY_OF_WEEK =7;
反编译之前的方法如图
修改之后的图,其他的数字依次类推
6.MeasureSpec.makeMeasureSpec(xx, int)
反编译的代码中MeasureSpec.makeMeasureSpec(xx, int)的第二个参数是个int类型的数,这个比较简单,直接看文档或者源码即可找到:
源码:
public static class MeasureSpec {
public static final int UNSPECIFIED = 0;
public static final int EXACTLY = 1073741824;
public static final int AT_MOST = -2147483648;
则对于:
MeasureSpec.makeMeasureSpec(xx, 0)或MeasureSpec.makeMeasureSpec(getWidth(), Integer.MIN_VALUE)
我们应该修改为
MeasureSpec.makeMeasureSpec(xx, View.MeasureSpec.UNSPECIFIED)
其他依次类推
7.animator.setRepeatMode(int);
这个是ValueAnimator类设置动画的属性,
public static final int RESTART = 1;
public static final int REVERSE = 2;
public static final int INFINITE = -1;
设置也是根据反编译的值进行
8. setColor(-17367043)
反编译的代码中会有很多setColor(int)的情况,
比如setColor(-16777216),这个值比较特别,能轻易的查到Android文档中对这个整数的定义:
public static final int BLACK. Added in API level 1 Constant Value: -16777216 ( 0xff000000).
也就是说setColor(-16777216)中-16777216对应的颜色是BLACK(0xff000000),那么其他系统未定义成某个颜色名的值呢?
-16777216 对应 0xff000000 -1 对应 0xffffffff 0xffffff 的值
16777215 那么对任意的 setColor(int)中的int值,
我们可以:0xffffffff+(int)+1 或 0xffffffff-(-int+1)
则对于 :setColor(-16777216)
可写成 :setColor(0xffffffff - 16777215)) 或 setColor(-16777216 + 1 + 0xffffffff))
这样,我们就不用查文档寻找特定的颜色值,也能解决任意颜色的设置。
9.new Runnable()...
反编译代码中
new Runnable() {
final /* synthetic */ AbstractButton a;
{
this.a = r1;
}
public final void run() {
this.a.xxxxx();
}};
可直接去掉成员变量:
new Runnable() {
public final void run() {
xxxxx();
}};
10.new Handler()...
同9上面,直接去掉成员变量:
new Handler() {
final /* synthetic */ ButtonSave a;
{ this.a = r1;
}
public final void handleMessage(Message message){
this.a.xxx();
} }
;//修改为
new Handler() {
public final void handleMessage(Message message) {
xxx();
} };
11.context.getSystemService("layout_inflater")
直接看源码即可:
public static final String POWER_SERVICE = "power";
public static final String WINDOW_SERVICE = "window";
public static final String LAYOUT_INFLATER_SERVICE = "layout_inflater";
public static final String ACCOUNT_SERVICE = "account";
public static final String ACTIVITY_SERVICE = "activity";
public static final String ALARM_SERVICE = "alarm";
public static final String NOTIFICATION_SERVICE = "notification";
public static final String ACCESSIBILITY_SERVICE = "accessibility";
...
则context.getSystemService("layout_inflater") ==> context.getSystemService(Context.LAYOUT_INFLATER_SERVICE)
其他依次类推。
12.intent.setFlags()
先看源码:
Intent implements Parcelable, Cloneable {
public static final int FLAG_GRANT_READ_URI_PERMISSION = 1;
public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 2;
public static final int FLAG_FROM_BACKGROUND = 4;
public static final int FLAG_DEBUG_LOG_RESOLUTION = 8;
public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 16;
public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 32;
public static final int FLAG_ACTIVITY_NO_HISTORY = 1073741824;
public static final int FLAG_ACTIVITY_SINGLE_TOP = 536870912;
public static final int FLAG_ACTIVITY_NEW_TASK = 268435456;
public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 134217728;
public static final int FLAG_ACTIVITY_CLEAR_TOP = 67108864;
public static final int FLAG_ACTIVITY_FORWARD_RESULT = 33554432;
public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 16777216;
public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 8388608;
public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 4194304;
public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 2097152;
public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 1048576;
public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 524288;
public static final int FLAG_ACTIVITY_NO_USER_ACTION = 262144;
public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 131072;
public static final int FLAG_ACTIVITY_NO_ANIMATION = 65536;
public static final int FLAG_ACTIVITY_CLEAR_TASK = 32768;
public static final int FLAG_ACTIVITY_TASK_ON_HOME = 16384;
public static final int FLAG_RECEIVER_REGISTERED_ONLY = 1073741824;
public static final int FLAG_RECEIVER_REPLACE_PENDING = 536870912;
public static final int FLAG_RECEIVER_FOREGROUND = 268435456;
那么对于intent.setFlags(int); 中 int值是上面四种之一的话就比较简单,例如:
intent.setFlags(536870912); ==> intent.setFlags(PendingIntent.FLAG_NO_CREATE);
但是遇到一个比较特别的:intent.setFlags(335544320);
源码里根本没有这样一个值啊,其实intent.setFlags( A | B )是可以使用|(或运算)的,那么:
10000000000000000000000000000 = 268435456 | |
100000000000000000000000000 = 6710886410100000000000000000000000000 = 335544320
即 268435456 | 67108864 = 335544320
从而:
intent.setFlags(335544320);==>
intent.setFlags( FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_CLEAR_TOP )
或者
intent.setFlags( FLAG_RECEIVER_FOREGROUND | FLAG_ACTIVITY_CLEAR_TOP )
从 Codota 中搜索intent.setFlags(335544320);看到的是第一种情况,结合intent.setFlags()的用法,应该也是第一种情况。
网友评论