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 8439059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:54:03+00:00 2026-06-10T07:54:03+00:00

I really have no idea how to implement Share Intent into my codes. Could

  • 0

I really have no idea how to implement Share Intent into my codes. Could somebody assist me, Do i need to rewrite the whole code code? I’m using AsyncTask for my share intent. I would like to share my image using the share intent. Please check my below code, something is missing for “The method startActivity(Intent) is undefined for the type ShareImageTask” .

ShareImageTask.class

    public class ShareImageTask extends AsyncTask<String , String , String>
{
    private Context context;
    private ProgressDialog pDialog;
    String image_url;
    URL myFileUrl;
    String myFileUrl1;
    Bitmap bmImg = null;
    Intent share;


    public ShareImageTask(Context context) {
        this.context = context;
    }

    @Override
    protected void onPreExecute() {
        // TODO Auto-generated method stub

        super.onPreExecute();

        pDialog = new ProgressDialog(context);
        pDialog.setMessage("Downloading Image ...");
        pDialog.setIndeterminate(false);
        pDialog.setCancelable(false);
        pDialog.show();

    }

    @Override
    protected String doInBackground(String... args) {
        // TODO Auto-generated method stub

        try {  

            myFileUrl = new URL(args[0]);
            HttpURLConnection conn = (HttpURLConnection) myFileUrl.openConnection();   
            conn.setDoInput(true);   
            conn.connect();     
            InputStream is = conn.getInputStream();
            bmImg = BitmapFactory.decodeStream(is); 
        }
        catch (IOException e)
        {       
            e.printStackTrace();  
        }
        try {       

            String path = myFileUrl.getPath();
            String idStr = path.substring(path.lastIndexOf('/') + 1);
        File filepath = Environment.getExternalStorageDirectory();
        File dir = new File (filepath.getAbsolutePath() + "/Wallpaper/");
            dir.mkdirs();
            String fileName = idStr;
            File file = new File(dir, fileName);
            FileOutputStream fos = new FileOutputStream(file);
            bmImg.compress(CompressFormat.JPEG, 75, fos);   
            fos.flush();    
            fos.close();     
            share = new Intent(Intent.ACTION_SEND);
            share.setType("image/jpeg");

            share.putExtra(Intent.EXTRA_STREAM,file);

            context.startActivity(Intent.createChooser(share, "Share Image")); 
        }
        catch (Exception e)
                {
                    e.printStackTrace();  
                }




        return null;   
    }

    @Override
    protected void onPostExecute(String args) {
        // TODO Auto-generated method stub
                pDialog.dismiss();

    }


}
  • 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-10T07:54:05+00:00Added an answer on June 10, 2026 at 7:54 am

    Use this:

    context.startActivity(Intent.createChooser(share, "Share Image"));
    

    So you point to your Activity’s Context in your AsyncTask, and not to the AsyncTask itself. Right now you’re calling a method AsyncTask::startActivity(), but that doesn’t exist. Because you’re in the inner class, you gotta have the object you want to call startActivity() on. That’s the context variable you set.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I really appreciate if someone could give me an idea how to implement this.
This probably sounds really stupid but I have noo idea how to implement jquery's
I have this idea which I'm not really sure how to implement. The idea
I really have no idea what I did to cause this exception, but I
I really have no idea why I'm struggling with this so much. I'm scraping
I really have no idea how to go about this. So far all I
I have really no idea why I'm asking this as this a really completely
I have a really hard time searching for this, because I have no idea
Sorry about the strange title. I really have no idea how to express it
Since I don't really have a good idea for word to search with myself

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.