[Q] Overlay an image prior to taking screenshot topic

SOCIALIZE IT ⇨

Hello everyone,

I'm new to java-android programming and have what is probably a very basic question.

I purchased some source code to reskin and whoever wrote the code was either sloppy or very talented because it's difficult for me to follow with my limited training.

I've managed to get through most of what I wanted to do but this part is throwing me off.

I have a button that captures the current screen view and brings up an intent share popup window allowing the user to select whatever program they have for sharing the screenshot.

That works fine, however the app has a banner add at the bottom of the screen that I would like to overlay with another image when the user presses the share button. Then after the screenshot is saved I want the overlayed image to disappear and they can continue on.

// Here is a code snip-it of what I have that works for capturing and sharing:


case R.id.ShareButton:

// Capture the screenshot:

View v = view.getRootView();
v.setDrawingCacheEnabled(true);
Bitmap b = v.getDrawingCache();
String extr = Environment.getExternalStorageDirectory().toString ();
File myPath = new File(extr, getString(R.string.myImage)+".png");
FileOutputStream fos = null;
try {
fos = new FileOutputStream(myPath);
b.compress(Bitmap.CompressFormat.JPEG, 100, fos);
fos.flush();
fos.close();
MediaStore.Images.Media.insertImage( getContentResolver(), b,
"Screen", "screen");
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}


// Share the screenshot:

Intent share = new Intent(Intent.ACTION_SEND);

// If you want to share a png image only, you can do:

// setType("image/png"); OR for jpeg: setType("image/jpeg");
share.setType("image/*");

// Make sure you put example png image named myImage.png in your
// directory
String imagePath = Environment.getExternalStorageDirectory()
+ "/myImage.png";

File imageFileToShare = new File(imagePath);

Uri uri = Uri.fromFile(imageFileToShare);
share.putExtra(Intent.EXTRA_STREAM, uri);

startActivity(Intent.createChooser(share, "Post your WINNINGS!"));


break;

xda-developers


0 commentaires:

Enregistrer un commentaire