杂七杂八 android小工具类
来源:互联网 发布:三星s5网络模式仅限2g 编辑:程序博客网 时间:2024/05/29 18:02
一、关闭软件盘
public void closeInput() { InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); if (inputMethodManager != null && HelpActivity.this.getCurrentFocus() != null) { inputMethodManager.hideSoftInputFromWindow(HelpActivity.this.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } }
二、检测版本号
android.os.Build.VERSION.SDK_INT < 18
三、是否支持蓝牙
BluetoothManager bluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE); mBluetoothAdapter = bluetoothManager.getAdapter(); if (mBluetoothAdapter == null) {}
四、是否有连接网络
ConnectivityManager cwjManager = (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo info = cwjManager.getActiveNetworkInfo(); if (info != null && info.isAvailable()) { return true; } else { return false; }
五、小线程
new Thread(new Runnable() { @Override public void run() { InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); if (inputMethodManager != null && PkiHardWareActivity.this.getCurrentFocus() != null) { inputMethodManager.hideSoftInputFromWindow(PkiHardWareActivity.this.getCurrentFocus() .getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } } }).start();
六、textview 文本复制
// TODO Auto-generated method stub ClipboardManager cmb = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); final String temp = textView1.getText().toString(); cmb.setText(temp.toString()); Toast.makeText(context, "Copy success", Toast.LENGTH_SHORT).show(); Vibrator vibrator; vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); long[] pattern = { 100, 100, 0, 0 }; vibrator.vibrate(pattern, -1); return false;
七、动态布局
tv_left.setLayoutParams(new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); RelativeLayout.LayoutParams lp = (LayoutParams) tv_left.getLayoutParams(); lp.addRule(CENTER_VERTICAL); tv_left.setLayoutParams(lp);
0 0
- 杂七杂八 android小工具类
- android 自己总结的小工具类
- 分享个android开发小工具类
- android系统的 一些小工具类
- Android颜色小工具
- 小工具:android logpkg
- android 小工具
- android 小工具集合
- android 开发小工具
- Android小工具
- Android小工具
- 小工具类
- Java 小工具类
- java小工具类
- 一个小工具类
- Android APK 反编译小工具
- Android开发小工具总结
- android基本基本小工具
- 使用笔记本建立免费无线热点 Create Free Ad-Hoc NetWork
- 关于Web Worker的一些心得
- 黑马程序员—05OC核心语法_02
- Android中集成第三方库的方法和问题
- 数据库操作(使用FMDB)
- 杂七杂八 android小工具类
- From feature descriptors to deep learning: 20 years of computer vision
- 每天进步一点
- 黑马程序员—06OC内存管理_01
- hadoop学习之hadoop完全分布式集群安装
- POJ 3252 Round Numbers (数位DP)
- 检测远程端口是否打开
- 黑马程序员—07OC内存管理_02
- tower of hanoi(汉诺塔)问题 按步骤分析--取自《严蔚敏·数据结构》 P55