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

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

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 - Adding taken picture into the picture content provider

Adding taken picture into the picture content provider

Quickly share your Android Code Snippets here...

Adding taken picture into the picture content provider

Postby coding_android » Sun Oct 05, 2008 10:50 am

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. // Add some parameters to the image that will be stored in the Image ContentProvider
  2. int UNIQUE_BUCKET_ID = 1337;
  3. ContentValues values = new ContentValues(7);
  4. values.put(MediaStore.Images.Media.DISPLAY_NAME,"name of the picture");
  5. values.put(MediaStore.Images.Media.TITLE,"Thats the title of the image");
  6. values.put(MediaStore.Images.Media.DESCRIPTION, "Some description");
  7. values.put(MediaStore.Images.Media.BUCKET_DISPLAY_NAME,"Album name");
  8. values.put(MediaStore.Images.Media.BUCKET_ID,UNIQUE_BUCKET_ID);
  9. values.put(MediaStore.Images.Media.DATE_TAKEN,System.currentTimeMillis());
  10. values.put(MediaStore.Images.Media.MIME_TYPE, "image/jpeg");
  11.                
  12. // Inserting the image meta data inside the content provider
  13. Uri uri = getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
  14.  
  15. // Filling the real data returned by the picture callback function into the content provider
  16. try {
  17.         OutputStream outStream = getContentResolver().openOutputStream(uri);
  18.         outStream.write(buffer); // buffer is the data stream returned by the picture callback
  19.         outStream.close();
  20.       }catch (Exception e) {
  21.         Log.e(TAG, "Exception while writing image", e);
  22.       }
Parsed in 0.012 seconds, using GeSHi 1.0.8.4


SDK Version compatible: 0.9, 1.0
If you got job opportunities for me. Just drop me a personal message. - Android developement - integrating social media into Android
User avatar
coding_android
Moderator
Moderator
 
Posts: 76
Joined: Mon May 05, 2008 10:22 am
Location: Germany

Top

Postby ninor » Mon Oct 06, 2008 8:12 am

2 questions: :oops:
What's the picture content provider?
Where do the images get stored?
Image AndDev: Your Android Development Community / Tutorials | Here's my Basic ToolKit
User avatar
ninor
Moderator
Moderator
 
Posts: 180
Joined: Thu Aug 14, 2008 6:30 pm
Location: Barcelona, Spain

Postby Artur79 » Sun Nov 23, 2008 2:18 pm

could you put full working example, please.
Artur79
Developer
Developer
 
Posts: 26
Joined: Fri Sep 26, 2008 12:53 pm

Postby MrSnowflake » Tue Dec 16, 2008 11:22 pm

[s]How could one play a media file from a ContentProvider, as it only returns an OutputStream and MediaPlayer doesn't take OutputStream.

You could manually write the outputstream to a temp file, but that's just bogus...[/s]

Well apparently ContentProvider has a openFileDescriptor(Uri, String), which returns a ParcelableFileDescriptor, which in part has a method called getFileDescriptor(), wich can be used with MediaPlayer!
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Postby doubleslash » Mon Mar 09, 2009 7:35 am

Is the picture saved in the app's local directory? It doesn't show up in Pictures. How to make it show up there?
doubleslash
Developer
Developer
 
Posts: 30
Joined: Fri Feb 13, 2009 6:05 am

Postby MrSnowflake » Mon Mar 09, 2009 1:32 pm

You probably can't as the pictures are probably saved to the files directory of the ContentProvider's directory, which, probably, is private.
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Top

Return to Code Snippets for Android

Who is online

Users browsing this forum: No registered users and 5 guests