private int width,height;方法一:        DisplayMetrics dm = new DisplayMetrics();        getWindowManager().getDefaultDisplay().getMetrics(dm);        width = dm.widthPixels;        height = dm.heightPixels;方法二:        Display display = getWindowManager().getDefaultDisplay();        width = display.getWidth();        height = display.getHeight();

Service 中获取的方法:

DisplayMetrics dm = new DisplayMetrics();        dm = name.this.getApplicationContext().getResources().getDisplayMetrics();        width = dm.widthPixels;        height = dm.heightPixels;

更多相关文章

  1. android的ndk修改app_platform的方法,亲测绝对可行
  2. android调用NotificationManager.notify无效,通知栏不显示
  3. Android权限
  4. android隐藏以及显示软键盘以及不自动弹出键盘的方法
  5. Android(安卓)Keep screen on(保持屏幕唤醒)
  6. Android获取系统的内存使用率
  7. 浅谈Java中Collections.sort对List排序的两种方法
  8. Python list sort方法的具体使用
  9. python list.sort()根据多个关键字排序的方法实现

随机推荐

  1. Android中设置文本颜色的三种方法
  2. android junit入门(一) JUNIT测试
  3. android监听网络变化
  4. Android淘宝好评星级进度条RatingBar原来
  5. Android获取手机方向
  6. Android布局属性详解
  7. Delphi XE5 for android 调用Java类库必
  8. Android(安卓)Button 点击时替换背景颜色
  9. Android——JSONObject解析JSON数据
  10. Android客户端与J2EE服务器的互联