0

I want to save and display the captured image in the next activity.I have written the code but its not working what modifications I need to do in that code.

 camera.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    Log.d("Coming in the camera intent","coming in yhe camera intent");
                    String filePath = Environment.getExternalStorageDirectory()+ "/s1.jpeg";
                    File file = new File(filePath);
                    Uri output = Uri.fromFile(file);
                    Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); 
                    startActivityForResult(cameraIntent, CAMERA_REQUEST); 
                }
            });
        }
        protected void onActivityResult(int requestCode, int resultCode, Intent data) {  
            if (requestCode == CAMERA_REQUEST && resultCode == RESULT_OK) {  
                Log.d("Coming in the if loop","coming in the if loop");
                Bitmap photo = (Bitmap) data.getExtras().get("data"); 
                Intent i1=new Intent(MyMenu.this,FullScreen.class);
                i1.putExtra("photooo",photo);
                startActivity(i1);
            }  
        } 

and Receiving activity where I want to save and display the image

image=(ImageView)findViewById(R.id.image);
        note=(ImageButton)findViewById(R.id.note);
        tick=(ImageButton)findViewById(R.id.tick);
        cross=(ImageButton)findViewById(R.id.cross);
        Intent intent = getIntent();
        Bitmap photo = (Bitmap) intent.getParcelableExtra("photooo");
        image.setImageBitmap(photo);
    }

stack

10-25 12:50:30.459: E/AndroidRuntime(27740): java.lang.RuntimeException: Unable to resume activity {com.example.babysnap/com.example.babysnap.MyMenu}: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1888, result=-1, data=Intent { act=inline-data (has extras) }} to activity {com.example.babysnap/com.example.babysnap.MyMenu}: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.babysnap/com.example.babysnap.FullScreen}; have you declared this activity in your AndroidManifest.xml?
user370305
  • 108,599
  • 23
  • 164
  • 151
user1758835
  • 215
  • 4
  • 17

3 Answers3

1

It seems your FullScreen Activity is not declared in AndroidManifest.xml file.

Check it. And declare it.

user370305
  • 108,599
  • 23
  • 164
  • 151
  • Thanks,Its working fine after adding the activity but the image is getting saved on default location not on the specified path – user1758835 Oct 26 '12 at 05:13
0

Instead of Bitmap try to pass imagepath. You already got Uri output; From this get fileapath.

String imagepath=output.getPath(); then intent.putExtra("imagepath",imagepath)

In other Activity get this string:

String path= getIntent().getStringExtra("imagepath"). then

Bitmap myBitmap = BitmapFactory.decodeFil(path);    
ImageView myImage = (ImageView) findViewById(R.id.imageviewTest);
myImage.setImageBitmap(myBitmap);

Read here. You can do it using Byte Array also

Community
  • 1
  • 1
Abhi
  • 8,935
  • 7
  • 37
  • 60
0

First Convert Image into Byte Array and then pass into Intent and in next activity get byte array from Bundle and Convert into Image(Bitmap) and set into ImageView.

Convert Bitmap to Byte Array:-

Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bmp.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray();

Pass byte array into intent:-

Intent intent = new Intent(this, NextActivity.class);
intent.putExtra("picture", byteArray);
startActivity(intent);

Get Byte Array from Bundle and Convert into Bitmap Image:-

Bundle extras = getIntent().getExtras();
byte[] byteArray = extras.getByteArray("picture");

Bitmap bmp = BitmapFactory.decodeByteArray(byteArray, 0, byteArray.length);
ImageView image = (ImageView) findViewById(R.id.imageView1);
image.setImageBitmap(bmp);

And write below code for declare Activity in Androidmanifest.xml.

<activity
    android:name=".FullScreen"
    android:label="@string/app_name">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
</activity>
Dipak Keshariya
  • 22,193
  • 18
  • 76
  • 128