I Want To Implement Share Functionality in my App.And I Want To Share Multiple Product At A Time For That I Have To Take Screenshot Of All Layout.
Any Idea About It.
I Want To Implement Share Functionality in my App.And I Want To Share Multiple Product At A Time For That I Have To Take Screenshot Of All Layout.
Any Idea About It.
Try THIs:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
viewpager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int i, float v, int i1) {
}
@Override
public void onPageSelected(int i) {
// here put belowcode
}
@Override
public void onPageScrollStateChanged(int i) {
}
});
step1:
Bitmap b = Bitmap.createBitmap(yourLyout.getWidth(), yourLyout.getHeight(), Bitmap.Config.ARGB_8888);
int weight,height;
weight = yourLyout.getWidth();
height = yourLyout.getHeight();
Bitmap cs = Bitmap.createBitmap(weight, height, Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(cs);
c.drawBitmap(b,0,0,null);
yourLyout.draw(c);
step2
//First we get the root of sdcard/or ExternalStorage and then create a folder named photoEmail in sdcard by using mkdirs() method.
Random generator = new Random();
int n = 10000;
n = generator.nextInt(n);
String root = Environment.getExternalStorageDirectory() + "/PhotoEmail";
File file = new File(root);
file.mkdirs();
//Name the image file in sdcard with images.png
//File file1 = new File(root + "/" +"images"+n".png");
//Now open the file and compress our bitmap image and make the file image file with png ow Open
fos = new FileOutputStream(file1);
if (fos != null) {
cs.compress(Bitmap.CompressFormat.PNG, 90, fos);
fos.close();
}
step3:
Intent picMessageIntent = new Intent(android.content.Intent.ACTION_SEND);
picMessageIntent.setType("message/rfc822");#sthash.zPwDJd6s.dpuf
File downloadedPic = new File("/sdcard/PhotoEmail/images.png")
picMessageIntent.putExtra(Intent.EXTRA_STREAM,Uri.fromFile(downloadedPic));
startActivityForResult(picMessageIntent, 1);