| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,4 +14,5 @@ | |||
| 14 | 14 | 13.非常全面的一个图片库,个人开发者必看 | |
| 15 | 15 | 14.各种常用单位转换以及屏幕尺寸获取:获得屏幕宽度(像素),获得屏幕高度(像素),px2dip,dip2px,px2sp,sp2px | |
| 16 | 16 | 15. 压缩图片,防止Bitmap过大导致OOM | |
| 17 | + 16.请求打开蓝牙 | ||
| 17 | 18 | ......未完待续...... | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,6 +5,7 @@ | |||
| 5 | 5 | */ | |
| 6 | 6 | ||
| 7 | 7 | import android.app.Activity; | |
| 8 | + import android.bluetooth.BluetoothAdapter; | ||
| 8 | 9 | import android.content.Context; | |
| 9 | 10 | import android.content.Intent; | |
| 10 | 11 | import android.content.pm.PackageInfo; | |
@@ -203,6 +204,7 @@ public void deletFiles(File file) { | |||
| 203 | 204 | //http://www.iconfont.cn/collections | |
| 204 | 205 | ||
| 205 | 206 | //14.各种单位转换 | |
| 207 | + | ||
| 206 | 208 | /** | |
| 207 | 209 | * 获得屏幕宽度(像素) | |
| 208 | 210 | * | |
@@ -282,11 +284,13 @@ public static int sp2px(Context context, float spValue) { | |||
| 282 | 284 | } | |
| 283 | 285 | ||
| 284 | 286 | //15. 压缩图片,防止Bitmap过大导致OOM | |
| 287 | + | ||
| 285 | 288 | /** | |
| 286 | 289 | * 谷歌推荐使用方法,从资源中加载图像,并高效压缩,有效降低OOM的概率 | |
| 287 | - * @param res 资源 | ||
| 288 | - * @param resId 图像资源的资源id | ||
| 289 | - * @param reqWidth 要求图像压缩后的宽度 | ||
| 290 | + * | ||
| 291 | + * @param res 资源 | ||
| 292 | + * @param resId 图像资源的资源id | ||
| 293 | + * @param reqWidth 要求图像压缩后的宽度 | ||
| 290 | 294 | * @param reqHeight 要求图像压缩后的高度 | |
| 291 | 295 | * @return | |
| 292 | 296 | */ | |
@@ -304,7 +308,7 @@ public Bitmap decodeSampledBitmapFromResource(Resources res, int resId, int reqW | |||
| 304 | 308 | options.inJustDecodeBounds = false; | |
| 305 | 309 | //将options.inPreferredConfig改成Bitmap.Config.RGB_565, | |
| 306 | 310 | // 是默认情况Bitmap.Config.ARGB_8888占用内存的一般 | |
| 307 | - options.inPreferredConfig= Bitmap.Config.RGB_565; | ||
| 311 | + options.inPreferredConfig = Bitmap.Config.RGB_565; | ||
| 308 | 312 | return BitmapFactory.decodeResource(res, resId, options); | |
| 309 | 313 | } | |
| 310 | 314 | ||
@@ -336,4 +340,11 @@ public int calculateInSampleSize(BitmapFactory.Options options, | |||
| 336 | 340 | ||
| 337 | 341 | return inSampleSize; | |
| 338 | 342 | } | |
| 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 | + } | ||
| 339 | 350 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments