- 获取状态栏高度
private static int getStatusBarHeight() {
Class<?> c = null;
Object obj = null;
Field field = null;
int x = 0, sbar = 0;
try {
c = Class.forName("com.android.internal.R$dimen");
obj = c.newInstance();
field = c.getField("status_bar_height");
x = Integer.parseInt(field.get(obj).toString());
sbar = mContext.getResources().getDimensionPixelSize(x);
} catch (Exception e1) {
e1.printStackTrace();
}
return sbar;
}
- 让悬浮窗覆盖状态栏
public class ToastUtils {
private static Toast toast;
private static Context mContext;
public static void show(Context context,String text,int duration){
mContext = context;
if(null == toast){
toast = Toast.makeText(mContext, text, duration);
}
else{
toast.setText(text);
toast.setDuration(duration);
}
toast.show();
}
public static void show(Context context,int id,int duration){
mContext = context;
if(null == toast){
toast = Toast.makeText(mContext, id, duration);
}
else{
toast.setText(id);
toast.setDuration(duration);
}
toast.show();
}
}
Android AccessibilityService 使用详解
Android AccessibilityService 使用详解AccessibilityService实例
AccessibilityService实例