0

In my Android Application I want to implement functionality of sharing screenshot. For sharing purpose I am using ShareActionProvider as guided by this link :-http://developer.android.com/training/sharing/shareaction.html

Code for setting share Intent which is in onCreateOptionMenu as below:-

public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.countdown, menu);
    mActionReward = menu.findItem(R.id.action_rewards);
    mActionShare = menu.findItem(R.id.menu_share);

    mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(mActionShare);
    updateShareIntent();
    mShareActionProvider.setShareIntent(emailIntent);    
    return super.onCreateOptionsMenu(menu);
}

where "emailIntent" is class field updateShareIntent() is method to update Intent which is as follows :-

 private void updateShareIntent() {
    try {
        File file = new File(saveImage(false));
        MediaStore.Images.Media.insertImage(getContentResolver(), file.getAbsolutePath(),getResources().getString(R.string.title), "");

        emailIntent = new Intent(android.content.Intent.ACTION_SEND);
        emailIntent.setType("jpeg/image");
        emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));

    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }
}

When user share the screenshot , screenshot image is screen that comes while starting the application/activity and not current. Kindly provide me solution to share current screenshot. It will be helpful for me.

void pointer
  • 575
  • 2
  • 8
  • 20
  • 1
    `ShareActionProvider` is not designed for capturing what should be shared at the time of the sharing. AFAIK, you will need to use something else, such as a regular action bar item, where you then get control when the user clicks it, capture your screenshot, then use `startActivity()` on your `ACTION_SEND` `Intent`. – CommonsWare May 22 '15 at 13:42
  • Ok. I will use ACTION_SEND Intent for the same.Thanks for help. – void pointer May 27 '15 at 12:15

0 Answers0