Android截屏表面视图显示黑屏
View view = MainActivity.getView();view.setDrawingCacheEnabled(true);Bitmap screen = Bitmap.createBitmap(view.getDrawingCache(true));.. save Bitmap
view = new GameView(this);view.setLayoutParams(new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.FILL_PARENT,
RelativeLayout.LayoutParams.FILL_PARENT));public static SurfaceView getView() {
return view;}public class GameView extends SurfaceView implements SurfaceHolder.Callback {private static SurfaceHolder surfaceHolder;...etcCanvas canvas = surfaceHolder.lockCanvas(null);
if (canvas != null) {
Game.draw(canvas);...public static void share() {
Bitmap screen = GameView.SavePixels(0, 0, Screen.width, Screen.height);
Calendar c = Calendar.getInstance();
Date d = c.getTime();
String path = Images.Media.insertImage(
Game.context.getContentResolver(), screen, "screenShotBJ" + d + ".png", null);
System.out.println(path + " PATH");
Uri screenshotUri = Uri.parse(path);
final Intent emailIntent = new Intent(
android.content.Intent.ACTION_SEND);
emailIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
emailIntent.putExtra(Intent.EXTRA_STREAM, screenshotUri);
emailIntent.setType("image/png");
Game.context.startActivity(Intent.createChooser(emailIntent,
"Share High Score:"));}
慕森王
随时随地看视频慕课网APP
相关分类