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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:52:29+00:00 2026-06-04T18:52:29+00:00

I am using Tab Activity as a main Activity in which it has 4

  • 0

I am using Tab Activity as a main Activity in which it has 4 tabs. One tab is Activity Group which has three buttons. Each button is one activity. I am using camera in one of those activity. I know its working because i have checked in the memory card the image get saved, but it doesn’t calling the Onactivityresult() method.

This is to display the ContentView

    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    View viewToLoad = LayoutInflater.from(this.getParent()).inflate(R.layout.enter_expenses, null);
    this.setContentView(viewToLoad);            

This code is used to take the image

             dbimgguid = UUID.randomUUID();
             imagename =dbimgguid.toString();
             Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
             photo = new File(Environment.getExternalStorageDirectory(), "Expenses"+imagename+".jpg");
             intent.putExtra(MediaStore.EXTRA_OUTPUT,Uri.fromFile(photo));
             imageurl = Uri.fromFile(photo); 
             startActivityForResult(intent, CAMERA_RECEIPTREQUEST); 

This is onactivity result

     @Override
     protected void onActivityResult(int requestCode, int resultCode, Intent data) {  
     super.onActivityResult(requestCode, resultCode, data);  
     System.out.println(requestCode);
     System.out.println(resultCode);
     switch(requestCode)
     {
     case CAMERA_RECEIPTREQUEST:  
         if(resultCode== Activity.RESULT_OK)
         {
         //Toast.makeText(this, "Receipt Image Saved", Toast.LENGTH_SHORT).show();
         BitmapFactory.Options options = new BitmapFactory.Options();
         options.inSampleSize = 8;
         //ImageView jpgView = (ImageView)findViewById(R.id.imageView1);
         Bitmap receipt = BitmapFactory.decodeFile(photo.toString(),options);  
         String image = "Expenses"+imagename+".jpg"; 
         Intent imagepass = new Intent(ExpensesActivity.this,ReviewReceiptImage.class);
         imagepass.putExtra("receipt", receipt);
         imagepass.putExtra("imagename", image);
         startActivityForResult(imagepass, CAMERA_CONFIRMRECEIPT); 
         Toast.makeText(this, "Receipt Image Saved", Toast.LENGTH_SHORT).show();
         }

     case CAMERA_CONFIRMRECEIPT:

         Toast.makeText(this, "Receipt Image Saved", Toast.LENGTH_SHORT).show();
         if(resultCode == CAMERA_CONFIRMRECEIPT)
         {
             take_receipt.setEnabled(false);
             take_receipt.setVisibility(View.GONE);
             show_receipt.setEnabled(true);
             show_receipt.setVisibility(View.VISIBLE);
         } 
         break;
     }
 }

Thanks for your help guys

  • 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-04T18:52:30+00:00Added an answer on June 4, 2026 at 6:52 pm

    I have solved my issue.Please see my answer below,

    I finally figured out/remembered that the issue is because Android will only allow a nested layer of sub-activities…ie sub-activities can’t nest sub-activitites. To solve this:

    call getParent().startActivityForResult() from your sub-activity
    your parent (the activitygroup) will be able to handle the onActivityResult. So I created a subclass of ActivityGroup and handled this onActivityResult.
    You can re-route that result back to the sub-activity if you need to. Just get the current activity by getLocalActivityManager().getCurrentActivity() . My sub-activities inherit from a custom activity so I added a handleActivityResult(requestCode, resultCode, data) in that subclass for the ActivityGroup to call.

    Answer for the above question with exact code

    ActivityGroup->SubActivities->onActivityResult->ActivityGroup(onActivityResult)->subActivity(onActivityResult)

    This is the ActivityGroup Class in which you have to define onActivityResult for all sub-activities,

    @Override
    public void onActivityResult(int requestCode,int resultCode, Intent data)
    {
    
             switch(requestCode)
                {
    
                case CAMERA_RECEIPTREQUEST:   
                if(resultCode == Activity.RESULT_OK)
                {
                ExpensesActivity activity = (ExpensesActivity) getLocalActivityManager().getCurrentActivity();
                activity.onActivityResult(requestCode, resultCode, data);
                }
                break;
    
                case CAMERA_CONFIRMRECEIPT:
                ExpensesActivity activity1 = (ExpensesActivity) getLocalActivityManager().getCurrentActivity();
                activity1.onActivityResult(requestCode, resultCode, data);   
                }
    
            }
    

    In Sub Activity, you have to set the view as below

        View viewToLoad = LayoutInflater.from(this.getParent()).inflate(R.layout.enter_time, null);
        this.setContentView(viewToLoad);
    

    Then in Sub- Activity onActivityResulty()

        @Override
        public void onActivityResult(int requestCode,int resultCode, Intent data)
        {
         //Some Code
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my Activity there is a TabView with 3 Tabs , each tab has
I am using below code to create three tab in activity but it gives
My application is Tab using ActivityGroup.I have done title of each activity using getParent().getParent().setTitle(New
I am making a activity using Tab-Host. I have two tabs. When I start
I am using TabActivity for my application. It has 4 tabs. Tab 1 is
I am using Ajax tab container control with 3 tabs. I have placed a
I am using storyboard with tab bar application. In one of tab I made
Problem I have a custom tab control using Chrome-shaped tabs that binds to a
I have a tab widget where one of the tabs is a chat-type feature.
I know how to develop the tab activity using xml layout and also i

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.