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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:31:35+00:00 2026-06-10T18:31:35+00:00

Calling startActivityForResult gives me ActivityNotFoundException . I wanted to know that is it even

  • 0

Calling startActivityForResult gives me ActivityNotFoundException. I wanted to know that is it even possible to call startActivityForResult inside onActivityResult? If yes then what could possibly be wrong with my code:

Here is the code:

OnPreferenceClickListener selectListener = new OnPreferenceClickListener() {

        public boolean onPreferenceClick(Preference preference) {
            Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
            photoPickerIntent.setType("image/*");
            photoPickerIntent.putExtra("crop","true");
            startActivityForResult(photoPickerIntent, 123);
            return false;
        }

    };

    protected void onActivityResult(int requestCode, int resultCode, Intent resultIntent) { 
        super.onActivityResult(requestCode, resultCode, resultIntent);

        if(requestCode == 123){
            if(resultCode == RESULT_OK){
                Uri selectedImage = resultIntent.getData(); // uri from user selection.
                File tempFile; // temporary File
                Uri tempUri; // temporary Uri

                try {
                    // initializing File
                    tempFile = File.createTempFile("crop", ".png", Environment.getExternalStorageDirectory());
                } catch (IOException e1) {
                    tempFile = null;
                }

                if(tempFile != null){
                    // initializing Uri
                tempUri = Uri.fromFile(tempFile);   
                }else{
                    tempUri = selectedImage;
                }

                Display display = getWindowManager().getDefaultDisplay(); 
                int width = display.getWidth();
                int height = display.getHeight();

                // creating new crop intent
                final Intent cropIntent = new Intent("com.android.camera.action.CROP");
                cropIntent.setData(selectedImage); // original image Uri
                cropIntent.putExtra("outputX", width);
                cropIntent.putExtra("outputY", height);
                cropIntent.putExtra("aspectX", width);
                cropIntent.putExtra("aspectY", height);
                cropIntent.putExtra("scale", true);
                cropIntent.putExtra("noFaceDetection", true);
                cropIntent.putExtra("output", tempUri);  // cropped image Uri
                cropIntent.putExtra("outputFormat", "png");
                startActivityForResult(cropIntent, 456);
            }

        if(requestCode == 456){
            if(resultCode == RESULT_OK){
                System.out.println("inside request code 456");
            }
        }
  • 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-10T18:31:36+00:00Added an answer on June 10, 2026 at 6:31 pm

    I have solved this error by removing photoPickerIntent.putExtra("crop","true");.

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

Sidebar

Related Questions

I am calling intents alot in my program and I thought that I could
I'm calling the default camera from my activity and then handling the onActivityResult. My
I am starting another activity by calling startActivityForResult() and after pressing back button my
Calling the WriteObject Method from a background thread is not possible! Is there a
Calling Html.RenderPartial(~/Views/Payments/MyControl.ascx); from a view works if MyControl.ascx is a control that directly inherits
So I can display Android's contact selecton activity by calling startActivityForResult(intent, PICK_CONTACT); and i
I'm playing around with the voice recognition API and wanted to know what I
Hi there I am calling an startActivityForResult() and trying to process the result in
Possible Duplicate: Calling camera from an activity, capturing an image and uploading to a
How to call startActivityForResult() method in back button, and please give me sample on

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.