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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:49:14+00:00 2026-06-17T19:49:14+00:00

I have two Activities first activity has the dynamic image view and on click

  • 0

I have two Activities first activity has the dynamic image view and on click i am calling the second activity where camera in invoked to capture a image, now i am able to invoke camera and capture a image but how would i pass that image to the previous activity and set to the image view.

String fileName = "testphoto.jpg";
    ContentValues values = new ContentValues();
    values.put(MediaStore.Images.Media.TITLE, fileName);
    values.put(MediaStore.Images.Media.DESCRIPTION,
            "Image capture by camera");
    values.put(MediaStore.Images.Media.MIME_TYPE, "image/jpeg");
    imageUri = getContentResolver().insert(
            MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
    Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
    intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
    startActivityForResult(intent, IMAGE_CAPTURE);
  • 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-17T19:49:16+00:00Added an answer on June 17, 2026 at 7:49 pm

    Finally I achieve using two activities with the help of startActivityForResult.

    check below piece code, hope its helpful you:

    main.xml

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".MainActivity" >
    
    
    
        <Button
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_alignParentTop="true"
            android:layout_marginLeft="57dp"
            android:layout_marginTop="84dp"
            android:text="Button" />
    
    
         <ImageView
            android:id="@+id/image"
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:layout_centerHorizontal="true"
            android:layout_centerVertical="true"
             />
    
    </RelativeLayout>
    

    FirstActivity.java

    It will open second activity with startActivityResult

    package com.example.demo_cameraintent;
    
    import java.io.File;
    
    import android.app.Activity;
    import android.content.Intent;
    import android.graphics.Bitmap;
    import android.graphics.BitmapFactory;
    import android.os.Bundle;
    import android.os.Environment;
    import android.util.Log;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.ImageView;
    import android.widget.ImageView.ScaleType;
    
    public class MainActivity extends Activity {
        ImageView image;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
            image=(ImageView)findViewById(R.id.image);
    
            String extStorageDirectory = Environment.getExternalStorageDirectory()
                    + "/testing";
    
          File xmlDirectory = new File(extStorageDirectory);
            if (!xmlDirectory.exists())
                xmlDirectory.mkdirs();
    
            Button btn=(Button)findViewById(R.id.button1);
    
            btn.setOnClickListener(new OnClickListener() {
    
                @Override
                public void onClick(View v) {
                    Intent i = new Intent(MainActivity.this, SecondActivity.class);
                    startActivityForResult(i, 1);
    
                }
            });
        }
    
        protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    
            if (requestCode == 1) {
    
                 if(resultCode == RESULT_OK){
    
                  String result=data.getStringExtra("result");
                  Log.d("*****************", "inside onactivityresult in main activity="+result);
    
                Bitmap bitmap = BitmapFactory.decodeFile(result);
                image.setImageBitmap(bitmap);
                image.setScaleType(ScaleType.FIT_XY);
    
            }
    
            if (resultCode == RESULT_CANCELED) {
    
    
    
                 //Write your code on no result return 
    
            }
            }//onAcrivityResult
    
    
        }
    }
    

    SecondActivity.java

    Here when its called it will directly open cameraIntent and within onActivityResult it will return back to Firstactivity with your output

    package com.example.demo_cameraintent;
    
    import java.io.File;
    
    import android.app.Activity;
    import android.content.Intent;
    import android.net.Uri;
    import android.os.Bundle;
    import android.os.Environment;
    import android.provider.MediaStore;
    import android.view.Menu;
    
    public class SecondActivity extends Activity {
        String filepath;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            //setContentView(R.layout.main);
    
             filepath = Environment.getExternalStorageDirectory()+"/testing/"+"test.jpg";
            System.out.println("thumbnail path~~~~~~"+filepath);
            File file = new File(filepath);
            Uri outputFileUri = Uri.fromFile(file);
    
    
            Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
            intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
            startActivityForResult(intent, 100);
    
    
        }
    
        @Override
        protected void onActivityResult(int requestCode, int resultCode, Intent data) {
            super.onActivityResult(requestCode, resultCode, data);
                if (requestCode == 100) {
    
                     Intent returnIntent = new Intent();
                     returnIntent.putExtra("result",filepath);
                     setResult(RESULT_OK,returnIntent);     
                     finish();
            }
    
    
        }
    
    
    
    }
    

    Manifest.xml

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.example.demo_cameraintent"
        android:versionCode="1"
        android:versionName="1.0" >
    
        <uses-sdk
            android:minSdkVersion="8"
            android:targetSdkVersion="16" />
    
        <application
            android:allowBackup="true"
            android:icon="@drawable/ic_launcher"
            android:label="@string/app_name"
            android:theme="@style/AppTheme" >
            <activity
                android:name="com.example.demo_cameraintent.MainActivity"
                android:label="@string/app_name" >
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
    
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity>
            <activity
                android:name="SecondActivity"
                android:label="@string/app_name" >
            </activity>
        </application>
    
        <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
        <uses-permission android:name="android.permission.CAMERA" />
    
        <uses-feature android:name="android.hardware.camera" />
    
    </manifest>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two activities. In first I come to the second activity from first
I have two activities or screens. The second activity has an AlertDialogBox with radiobuttons
I have two activities; Home is my first activity and Settings is my second
I have two different activities. The first launches the second one. In the second
hi i have two activities , first acivity has three icons one is invisible...when
In my project I have two activities or classes. In first activity I have
In my application I have two activities. In the first activity I have a
I have two activities. One activity has the main game and the other activity
I have an Android Honeycomb application with two activities; the first one has a
I have two activities. While switching to second activity by intent, it takes 3-4

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.