Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4362: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4364: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4365: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4366: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
anddev.org • View topic - How to import Gallery image in to our application

How to import Gallery image in to our application

Tutorials with advanced 'difficulty' and more Lines of Code.

How to import Gallery image in to our application

Postby maneesh_17 » Fri Sep 11, 2009 12:38 am

Hi,

I created SD card image in android emulator.I can access the images from SD card as well as gallery.I want to import selected image in to my app.

I am attaching the method for clicking the image item used in my code.

public void onItemClick(AdapterView<?> arg0, View arg1, int position, long rowId) {
Log.i(TAG,"onImageClick position= " + position + " rowId= "
+ rowId + " nCursor=" + mCursor.getCount());
try {
mCursor.moveToPosition(position);
long id = mCursor.getLong(mCursor.getColumnIndexOrThrow(MediaStore.Images.Thumbnails.IMAGE_ID));
//create the Uri for the Image
Uri uri = Uri.withAppendedPath(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, id+"");
selectImage = position;

//Uri selectedImage = intent.getData();

Intent intent = new Intent(Intent.ACTION_VIEW);
//intent = new Intent();
intent.setData(uri);
//intent.setClass(this,camera.class);
startActivity(intent);
Log.i("TAG","Pos :"+selectImage);
//startActivityForResult(new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI),selectImage);


} catch (CursorIndexOutOfBoundsException e) {
Log.i(TAG, "CursorIndexOutOfBoundsException " + e.getStackTrace());
}
}

I want to import the clicked image in to different activity means in my app.

If Somebody have an idea,please help me out.
maneesh_17
Junior Developer
Junior Developer
 
Posts: 17
Joined: Tue Sep 08, 2009 12:27 am
Location: Gurgaon,India

Top

Postby stifry » Fri Sep 11, 2009 12:50 am

You'll need to call the photo picker and use the onActivityResult of the calling activity to get the selected image:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
  3.  
  4.             photoPickerIntent.setType("image/*");
  5.  
  6.             startActivityForResult(photoPickerIntent, 1);
Parsed in 0.011 seconds, using GeSHi 1.0.8.4


.
.
.
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. @Override
  3.  
  4.         protected void onActivityResult(int requestCode, int resultCode,
  5.  
  6.                         Intent intent) {
  7.  
  8.                 super.onActivityResult(requestCode, resultCode, intent);
  9.  
  10.  
  11.  
  12.                 if (resultCode == RESULT_OK) {
  13.  
  14.                         Uri photoUri = intent.getData();
  15.  
  16.  
  17.  
  18.                         if (photoUri != null) {
  19.  
  20.                                 try {
  21.  
  22.                                         Bitmap bitmap = BitmapUtil.getBitmap(this,photoUri.toString());
  23.  
  24.                                         profilePic.setImageBitmap(bitmap);
  25.  
  26.                                         profilePicPath=photoUri.toString();
  27.  
  28.                                 } catch (Exception e) {
  29.  
  30.                                         e.printStackTrace();
  31.  
  32.                                 }
  33.  
  34.                         }
  35.  
  36.                 }
  37.  
  38.         }
Parsed in 0.010 seconds, using GeSHi 1.0.8.4
Visit Trackaroo.com!
Trackmaster - Motorsports Lap Timer
Dynomaster - Performance Dyno
Image Image
User avatar
stifry
Developer
Developer
 
Posts: 46
Joined: Tue Feb 17, 2009 7:50 pm

Postby maneesh_17 » Fri Sep 11, 2009 11:16 pm

Hi,

I want the selected Image in different activity like camera.
where I should define the onActivityResult method..in same activity or in Camera ??

what about this value 1 ?
startActivityForResult(photoPickerIntent, 1);
maneesh_17
Junior Developer
Junior Developer
 
Posts: 17
Joined: Tue Sep 08, 2009 12:27 am
Location: Gurgaon,India

Top

Return to Advanced Tutorials

Who is online

Users browsing this forum: No registered users and 5 guests