布局填充器的三种写法: 1.layoutInflater=layoutInflater.from(this); 2.layoutInflater=(LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE); 3.layoutIn...
分类:
其他好文 时间:
2014-12-05 10:27:56
阅读次数:
146
1、方法一(如果输入法在窗口上已经显示,则隐藏,反之则显示)InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);imm.toggleSoftInput(0, Inpu...
分类:
移动开发 时间:
2014-12-03 13:51:01
阅读次数:
156
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(view.getWindowToken(), 0)...
分类:
移动开发 时间:
2014-12-03 12:13:39
阅读次数:
164
最近做到一个项目,需要获取手机号。项目中使用的手机卡为电信卡,那么就以此为例吧。网上不符合需求的方法Google了一下,网上的做法如下://获取手机号码TelephonyManagertm=(TelephonyManager)this.getSystemService(Context.TELEPHO...
分类:
移动开发 时间:
2014-12-03 11:46:26
阅读次数:
219
context的功能如此强大,它是activity的父类。public abstract class Context { ... public abstract Object getSystemService(String name); //获得系统级服务 public abstract ...
分类:
移动开发 时间:
2014-12-02 20:29:43
阅读次数:
214
在Android1.5版本之前,实现挂断电话是非常容易的事,只需要调用TelephonyManager的endCall()方法就可以了,但在1.5版本之后,Google工程师为了手机的安全期间,把endCall的方法隐藏掉了。所以实现挂断电话可以通过反射的方法,执行endCall方法。具体实现如下:
TelephonyManager在源码里是这样描述的:Context.getSystemService(Context.TELEPHONY_SERVICE)},我们通过TELEPHONY_SERVICE系统服...
分类:
移动开发 时间:
2014-11-30 20:10:13
阅读次数:
277
//发送通知NotificationManager manger = (NotificationManager) this.getSystemService(NOTIFICATION_SERVICE);Notification noti = new Notification(R.drawable.i...
分类:
移动开发 时间:
2014-11-27 12:41:30
阅读次数:
158
1.WindowManager wm = (WindowManager) getContext() .getSystemService(Context.WINDOW_SERVICE); int width = wm.getDefaultDisplay(...
分类:
移动开发 时间:
2014-11-26 16:11:45
阅读次数:
152
1.注释内 。是三星设备可能不支持,需要更换的代码。2.mUsbManager。是getSystemService(Context.USB_SERVICE)获的。3. 从stackoverflow摘过来的。源地址找不到咧。 protected static final int STD_USB_REQ...
分类:
移动开发 时间:
2014-11-26 13:53:52
阅读次数:
257
退出应用的时候调用下面方法,就可以清楚数据了。
+ ActivityManager am = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
+ boolean res = am.clearApplicationUserData();
+ if (!res) {
+ ...
分类:
移动开发 时间:
2014-11-22 12:07:44
阅读次数:
176