package com.scribblegame;

import java.io.FileNotFoundException;
import java.io.OutputStream;

import android.app.Activity;
import android.content.ContentValues;
import android.graphics.Bitmap;
import android.graphics.Bitmap.CompressFormat;
import android.net.Uri;
import android.provider.MediaStore.Images.Media;
import android.util.Log;
import android.view.View;
import android.widget.Toast;

public class CaptureScreen extends Activity implements Runnable {

	public void run() {
		//while(true) 
		{
		View v = getWindow().getDecorView().getRootView();
	    v.setDrawingCacheEnabled(true);
	    Bitmap b = v.getDrawingCache();
	    Uri imageFileUri = getContentResolver().insert(Media.EXTERNAL_CONTENT_URI, new ContentValues());
	   	try {
	    	    OutputStream imageFileOS = getContentResolver().openOutputStream(imageFileUri);
	    	    b.compress(CompressFormat.JPEG, 90, imageFileOS);
	    	    Log.v("thread",imageFileUri.toString());
	            Toast t = Toast.makeText(this,"Saved!"+imageFileUri.toString(), 5000);
	            t.show();
	            
	           
	        } catch (FileNotFoundException e) {
	            Log.v("EXCEPTION",e.getMessage());
	        
	     
			}
		}
	}
}
