收集android的三个小tip

收集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.xml
Uri 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); 
//关闭软键盘,开启方法相同,这个方法是切换开启与关闭状态的
}

猜你喜欢

转载自jackyrong.iteye.com/blog/1662380