FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

新增:请求打开蓝牙 · SolveBugs/NormalCode@4280f02 · GitHub

Repository navigation

Commit 4280f02

Browse files
authored andcommitted
新增:请求打开蓝牙
1 parent fa82376 commit 4280f02

2 files changed

Lines changed: 16 additions & 4 deletions

File tree

‎README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@
1414
13.非常全面的一个图片库,个人开发者必看
1515
14.各种常用单位转换以及屏幕尺寸获取:获得屏幕宽度(像素),获得屏幕高度(像素),px2dip,dip2px,px2sp,sp2px
1616
15. 压缩图片,防止Bitmap过大导致OOM
17+
16.请求打开蓝牙
1718
......未完待续......

‎app/src/main/java/demo/zq/com/normalcode/Utils.java‎

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66

77
import android.app.Activity;
8+
import android.bluetooth.BluetoothAdapter;
89
import android.content.Context;
910
import android.content.Intent;
1011
import android.content.pm.PackageInfo;
@@ -203,6 +204,7 @@ public void deletFiles(File file) {
203204
//http://www.iconfont.cn/collections
204205

205206
//14.各种单位转换
207+
206208
/**
207209
* 获得屏幕宽度(像素)
208210
*
@@ -282,11 +284,13 @@ public static int sp2px(Context context, float spValue) {
282284
}
283285

284286
//15. 压缩图片,防止Bitmap过大导致OOM
287+
285288
/**
286289
* 谷歌推荐使用方法,从资源中加载图像,并高效压缩,有效降低OOM的概率
287-
* @param res 资源
288-
* @param resId 图像资源的资源id
289-
* @param reqWidth 要求图像压缩后的宽度
290+
*
291+
* @param res 资源
292+
* @param resId 图像资源的资源id
293+
* @param reqWidth 要求图像压缩后的宽度
290294
* @param reqHeight 要求图像压缩后的高度
291295
* @return
292296
*/
@@ -304,7 +308,7 @@ public Bitmap decodeSampledBitmapFromResource(Resources res, int resId, int reqW
304308
options.inJustDecodeBounds = false;
305309
//将options.inPreferredConfig改成Bitmap.Config.RGB_565,
306310
// 是默认情况Bitmap.Config.ARGB_8888占用内存的一般
307-
options.inPreferredConfig= Bitmap.Config.RGB_565;
311+
options.inPreferredConfig = Bitmap.Config.RGB_565;
308312
return BitmapFactory.decodeResource(res, resId, options);
309313
}
310314

@@ -336,4 +340,11 @@ public int calculateInSampleSize(BitmapFactory.Options options,
336340

337341
return inSampleSize;
338342
}
343+
344+
//16.请求打开蓝牙
345+
//REQUEST_ENABLE_BT自定义requestCode
346+
int REQUEST_ENABLE_BT = 0;
347+
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
348+
startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT) {
349+
}
339350
}

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL