FileOutputStream outputStream = new FileOutputStream(imageFile); int quality = 100; bitmap.compress(Bitmap.CompressFormat.JPEG, quality, outputStream); outputStream.flush(); outputStream.close();
openScreenshot(imageFile); } catch (Throwable e) { // Several error may come out with file handling or OOM e.printStackTrace(); } } //此方法调用图片查看器查看图片 privatevoidopenScreenshot(File imageFile){ Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); Uri uri = Uri.fromFile(imageFile); intent.setDataAndType(uri, "image/*"); mActivity.startActivity(intent); }
// Sets the flag to keep this screen on. It's recommended to do that during // the // handshake when setting up a game, because if the screen turns off, the // game will be // cancelled. voidkeepScreenOn(){ getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); }
// Clears the flag that keeps the screen on. voidstopKeepingScreenOn(){ getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); }