Sharing a png image in drawable folder

前端 未结 5 1748
野趣味
野趣味 2020-11-27 19:02

I am integrating share with the following code for the app.

private void socialShare()
    {
        Uri uri = Uri.parse(\"android.resource://com.example.myp         


        
5条回答
  •  庸人自扰
    2020-11-27 19:25

    I found solution where I should not copy image on sd card. Here it is:

        try {
            Uri imageUri = null;
            try {
                imageUri = Uri.parse(MediaStore.Images.Media.insertImage(this.getContentResolver(),
                        BitmapFactory.decodeResource(getResources(), R.drawable.fragment_menu_logo), null, null));
            } catch (NullPointerException e) {
            }
            String text = getString(R.string.share_text);
            // Launch the Google+ share dialog with attribution to your app.
            Intent shareIntent = new PlusShare.Builder(mActivity)
                    .setType("image/*")
                    .setText(text)
                    .addStream(imageUri)
                    .getIntent();
            startActivity(shareIntent);
        } catch (android.content.ActivityNotFoundException ex) {
            Toast.makeText(mActivity, mActivity.getString(R.string.share_google_plus_not_installed), Toast.LENGTH_LONG).show();
        }
    

提交回复
热议问题