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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:25:46+00:00 2026-05-30T13:25:46+00:00

This is my current code: public void onClick(View v) { final Intent pickIntent =

  • 0

This is my current code:

public void onClick(View v) {


                final Intent pickIntent = new Intent(Intent.ACTION_PICK_ACTIVITY);
                final Intent gallIntent=new Intent(Intent.ACTION_GET_CONTENT);
                gallIntent.setType("image/*"); 
                final Intent camIntent = new Intent("android.media.action.IMAGE_CAPTURE");
                pickIntent.putExtra(Intent.EXTRA_INTENT, camIntent);
                pickIntent.putExtra(Intent.EXTRA_INTENT, gallIntent);
                pickIntent.putExtra(Intent.EXTRA_TITLE, "Select Source");

                startActivityForResult(pickIntent, 0);
                if (bitmap == null) {
                    Toast.makeText(getApplicationContext(),
                            "Please select image", Toast.LENGTH_SHORT).show();
                } else {
                    dialog = ProgressDialog.show(CreatePod.this, "Uploading",
                            "Please wait...", true);
                    //new ImageUploadTask().execute();
                }
            }
        });

    }



    protected  void onActivityResult(int requestCode, int resultCode, Intent data){


     super.onActivityResult(requestCode, resultCode, data);


     if (resultCode == RESULT_CANCELED) {
         Toast toast = Toast.makeText(this,"camera cancelled", 10000);
         toast.show();
         return;
         }

        // lets check if we are really dealing with a picture

         if (requestCode == 0 && resultCode == RESULT_OK)
         {

             Bundle extras = data.getExtras();
                Bitmap b = (Bitmap) extras.get("data");
                //setContentView(R.layout.main);


                imgView.setImageBitmap(b);
           // save image to gallery
             String timestamp = Long.toString(System.currentTimeMillis());
             MediaStore.Images.Media.insertImage(getContentResolver(), b, timestamp, timestamp);

         }

    }

This gives the options Gallery and Camera(Actually, it shows an unsupported device in the place of camera. If I click on it, it gives NullPointerException and crashes. Is this the right way to do it? Or should I use PackageManger? If Yes, then how?

  • 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-05-30T13:25:48+00:00Added an answer on May 30, 2026 at 1:25 pm

    Looking of your code, I think you have a lack of basic android knowledge,

    Miss-use of onActivityResult(), its a method of Activity class, take out it from onClick()

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data)
    {
    
    }
    

    Just check basic android activity’s method and how to use them.

    Update:

    Look at Android-Activity

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

Sidebar

Related Questions

Here's my code: myButton.setOnClickListener( new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1)
This is my current code: public void copy(String file, String region) throws FileNotFoundException, IOException{
I used this code to print the current page: <form> <input type=button value=Print onClick=window.print();
I have this code: Dim pathString As String = HttpContext.Current.Request.MapPath(Banking.mdb) Dim odbconBanking As New
Here's my current code: public class MallMapActivity extends Activity { private final static String
I am having a bit of difficulty with this current code I have set
As a beginner in Ocaml, I have this current working code: ... let ch_in
My current code is this $swift = email::connect(); $swift->setSubject('hello') ->setFrom(array('alex@example.com.au' => 'Alex')) ->setTo(array('alex@example.com.au' =>
This question is related to a previous question of mine That's my current code
I'm running code that sometimes yields this: UInt32 current; int left, right; ... //sometimes

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.