Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8246169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T22:24:58+00:00 2026-06-07T22:24:58+00:00

I am creating a game, and trying to allow the user to share their

  • 0

I am creating a game, and trying to allow the user to share their win via text/facebook/etc. I am using the code below to grab an image from my res/drawable folder. I am pretty sure I am doing it right, but my app keeps crashing after I choose the send method (ex. facebook). Any help would be greatly appreciated.

Intent ShareIntent = new Intent(android.content.Intent.ACTION_SEND);
ShareIntent.setType("image/jpeg");
Uri winnerPic = Uri.parse("android.resource://com.poop.pals/" + R.drawable.winnerpic);
ShareIntent.putExtra(Intent.EXTRA_STREAM, winnerPic);
startActivity(ShareIntent);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T22:24:59+00:00Added an answer on June 7, 2026 at 10:24 pm

    Android’s resources are only accessible to your app via the resource apis, there is no regular file on the filesystem you can open in other ways.

    What you can do is to copy the file from the InputStream you can get to a regular file in a place that is accessible to other apps.

    // copy R.drawable.winnerpic to /sdcard/winnerpic.png
    File file = new File (Environment.getExternalStorageDirectory(), "winnerpic.png");
    FileOutputStream output = null;
    InputStream input = null;
    try {
        output = new FileOutputStream(file);
        input = context.getResources().openRawResource(R.drawable.winnerpic);
    
        byte[] buffer = new byte[1024];
        int copied;
        while ((copied = input.read(buffer)) != -1) {
            output.write(buffer, 0, copied);
        }
    
    } catch (FileNotFoundException e) {
        Log.e("OMG", "can't copy", e);
    } catch (IOException e) {
        Log.e("OMG", "can't copy", e);
    } finally {
        if (input != null) {
            try {
                input.close();
            } catch (IOException e) {
                // ignore
            }
        }
        if (output != null) {
            try {
                output.close();
            } catch (IOException e) {
                // ignore
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Creating a simple RPG game, first time using XNA. Trying to get my character
I'm creating a game engine using wxWidgets and OpenGL. I'm trying to set up
I'm creating a text-based game, and trying to implement procedural world generation. My initial
We're in the process of creating an iPhone game using cocos2d . We're trying
I'm creating a game in Java for fun and I'm trying to decide how
I'm trying to write a simple maze game, without using any deprecated OpenGL API
I am creating a game similar to Pokemon and right now I'm trying to
I am creating a side scrolling game in Flash (as3) and trying to keep
So I am trying to learn SDL and creating a small game. When the
I'm creating a simple tic tac toe game. I initialized my 3x3 board using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.