// 权限 @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR2) @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); permission(); StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder(); StrictMode.setVmPolicy(builder.build()); builder.detectFileUriExposure(); }
//动态授权
private void permission() { if (Build.VERSION.SDK_INT >= 23) { String[] mPermissionList = new String[]{ Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.CALL_PHONE, Manifest.permission.READ_LOGS, Manifest.permission.READ_PHONE_STATE, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.SET_DEBUG_APP, Manifest.permission.SYSTEM_ALERT_WINDOW, Manifest.permission.GET_ACCOUNTS, Manifest.permission.WRITE_APN_SETTINGS, Manifest.permission.CAMERA}; ActivityCompat.requestPermissions(MainActivity.this, mPermissionList, 123); } }
//将Bitmap转换成字符串
public String bitmapToString(Bitmap bitmap){
String string=null;
ByteArrayOutputStream bStream=new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG,75,bStream);
byte[]bytes=bStream.toByteArray();
string=Base64.encodeToString(bytes,Base64.DEFAULT);
return string;
}
// 将字符串转换成Bitmap类型
public Bitmap stringToBitmap(String string) {
Bitmap bitmap = null;
try {
byte[] bitmapArray;
bitmapArray = Base64.decode(string, Base64.DEFAULT);
bitmap = BitmapFactory.decodeByteArray(bitmapArray, 0,
bitmapArray.length);
} catch (Exception e) {
e.printStackTrace();
}
return bitmap;
}
//Glide加载原型图
Glide.with(this).load(bitmap).apply(RequestOptions.bitmapTransform(new CircleCrop())).into(imgMine);
// https://blog.csdn.net/shasha1021/article/details/73194669?utm_source=itdadao&utm_medium=referral