Hi everyone! I need help urgently! I am doing a project, and I need to know how am I going to store the images taken by my application's camera to my application's gallery?
Right now, I have developed my codes for my application camera to work, however, the pictures taken by the camera stores those images in the phone's default Gallery folder rather than my application's gallery folder.
How am I going to make it store inside my application gallery and be able to view back those pictures?
codes for my project for my application's camera are as followed:
package
Right now, I have developed my codes for my application camera to work, however, the pictures taken by the camera stores those images in the phone's default Gallery folder rather than my application's gallery folder.
How am I going to make it store inside my application gallery and be able to view back those pictures?
codes for my project for my application's camera are as followed:
package
com.package.try;
import
java.io.File;
import
android.app.Activity;
import
android.content.Intent;
import
android.graphics.Bitmap;
import
android.graphics.BitmapFactory;
import
android.net.Uri;
import
android.os.Bundle;
import
android.os.Environment;
import
android.provider.MediaStore;
import
android.util.Log;
import
android.view.View;
import
android.widget.Button;
import
android.widget.ImageView;
import
android.widget.TextView;
public
class Camera extends Activity
anyone please help?!
URGENT!!!
Do tell me how am I going to go about creating the gallery.java too!!
If possible, let me know the source codes!!
THANKS IN ADVANCE PEOPLE!!
{
protected ImageView _image;
protected TextView _field;
protected String _path;
protectedboolean_taken;
protected Button _button;
protected ImageView _image;
protected TextView _field;
protected String _path;
protectedboolean_taken;
protected Button _button;
protectedstaticfinal String PHOTO_TAKEN = "photo_taken";
@Override
publicvoid onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.camera);
publicvoid onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.camera);
_image = ( ImageView ) findViewById( R.id.image );
_field = ( TextView ) findViewById( R.id.field );
_button = ( Button ) findViewById( R.id.button );
_button.setOnClickListener( new ButtonClickHandler() );
_path = Environment.getExternalStorageDirectory() + "/images/try.jpg";
}
_field = ( TextView ) findViewById( R.id.field );
_button = ( Button ) findViewById( R.id.button );
_button.setOnClickListener( new ButtonClickHandler() );
_path = Environment.getExternalStorageDirectory() + "/images/try.jpg";
}
publicclass ButtonClickHandler implements View.OnClickListener
{
publicvoid onClick( View view ){
Log.i("try", "ButtonClickHandler.onClick()" );
startCameraActivity();
}
}
{
publicvoid onClick( View view ){
Log.i("try", "ButtonClickHandler.onClick()" );
startCameraActivity();
}
}
protectedvoid startCameraActivity()
{
Log.i("try", "startCameraActivity()" );
File file = new File( _path );
Uri outputFileUri = Uri.fromFile( file );
{
Log.i("try", "startCameraActivity()" );
File file = new File( _path );
Uri outputFileUri = Uri.fromFile( file );
Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE );
intent.putExtra( MediaStore.EXTRA_OUTPUT, outputFileUri );
intent.putExtra( MediaStore.EXTRA_OUTPUT, outputFileUri );
startActivityForResult( intent, 0 );
}
}
@Override
protectedvoid onActivityResult(int requestCode, int resultCode, Intent data)
{
Log.i( "try", "resultCode: " + resultCode );
switch( resultCode )
{
case 0:
Log.i( "try", "User cancelled" );
break;
protectedvoid onActivityResult(int requestCode, int resultCode, Intent data)
{
Log.i( "try", "resultCode: " + resultCode );
switch( resultCode )
{
case 0:
Log.i( "try", "User cancelled" );
break;
case -1:
onPhotoTaken();
break;
}
}
onPhotoTaken();
break;
}
}
protectedvoid onPhotoTaken()
{
Log.i( "try", "onPhotoTaken" );
{
Log.i( "try", "onPhotoTaken" );
_taken = true;
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = 4;
options.inSampleSize = 4;
Bitmap bitmap = BitmapFactory.decodeFile( _path, options );
_image.setImageBitmap(bitmap);
//_field.setVisibility( View.GONE );
}
}
@Override
protectedvoid onRestoreInstanceState( Bundle savedInstanceState){
Log.i( "try", "onRestoreInstanceState()");
if( savedInstanceState.getBoolean( Camera.PHOTO_TAKEN ) ) {
onPhotoTaken();
}
}
protectedvoid onRestoreInstanceState( Bundle savedInstanceState){
Log.i( "try", "onRestoreInstanceState()");
if( savedInstanceState.getBoolean( Camera.PHOTO_TAKEN ) ) {
onPhotoTaken();
}
}
@Override
protectedvoid onSaveInstanceState( Bundle outState ) {
outState.putBoolean( Camera.PHOTO_TAKEN, _taken );
}
}protectedvoid onSaveInstanceState( Bundle outState ) {
outState.putBoolean( Camera.PHOTO_TAKEN, _taken );
}
anyone please help?!
URGENT!!!
Do tell me how am I going to go about creating the gallery.java too!!
If possible, let me know the source codes!!
THANKS IN ADVANCE PEOPLE!!