收集android的三个小tip

来源:互联网 发布:单片机程序流程图文库 编辑:程序博客网 时间:2024/05/20 03:41
收集android的三个小tip

1)Android 开发中 HttpClient 超时设置
httpclient.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 3000);
//连接超时

httpclient.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, 5000);
//读取超时


2) 调用指定的程序打开指定文件,比如:
Intent i = new Intent();i.setComponent(new ComponentName("com.redirectin.rockplayer.android.unified", "com.redirectin.rockplayer.android.OpenRockPlayerActivity"));//包名 类名,可以用APKTool反编译apk包,查AndroidManifest.xmlUri name = Uri.parse("http://192.168.1.129/1.f4v");i.setData(name);startActivity(i);



3)开启与关闭软键盘
 
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);  //得到InputMethodManager的实例if (imm.isActive()) {//如果开启imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, InputMethodManager.HIDE_NOT_ALWAYS); //关闭软键盘,开启方法相同,这个方法是切换开启与关闭状态的}
原创粉丝点击