1. Sometimes the pictures taken are smaller than the actual ones
This may be related to the version.
But it's okay if it's over 2.0.
In 1.6, even if you use HW. Camera. maxhorizontalpixels and HW. Camera. maxverticalpixels.
Will get 1/4 of the original size
Intent imagecaptureintent = new intent (mediastore. action_image_capture );
File out = new file (environment. getexternalstoragedirectory (), "camera.jpg ");
Uri uri = URI. fromfile (out );
Imagecaptureintent. putextra (mediastore. extra_output, Uri );
Imagecaptureintent. putextra (mediastore. extra_video_quality, 1 );
Startactivityforresult (imagecaptureintent, result_capture_image );
No problem
The preceding directory is saved. Place where images are stored
Simpledateformat timestampformat = new simpledateformat ("yyyymmddhhmmssss ");
String filename = timestampformat. Format (new date ());
Contentvalues values = new contentvalues ();
Values. Put (media. Title, filename );
Values. Put (media. Description, "image from Android emulator ");
Photouri =
Getcontentresolver (). insert (mediastore. Images. Media. external_content_uri, values );
Intent inttphoto = new intent (mediastore. action_image_capture );
Inttphoto. putextra (mediastore. extra_output, photouri );
Startactivityforresult (inttphoto, 0 );
2. Then the related processing is
Private void savefullimage (){
Intent intent = new intent (mediastore. action_image_capture );
File file = new file (environment. getexternalstoragedirectory (), "test.jpg ");
Outputfileuri = URI. fromfile (File );
Intent. putextra (mediastore. extra_output, outputfileuri );
Startactivityforresult (intent, take_picture );
}
@ Override
Protected void onactivityresult (INT requestcode, int resultcode, intent data ){
If (requestcode = take_picture) & (resultcode = activity. result_ OK )){
// Check if the result contains des a thumbnail bitmap
If (Data = NULL ){
// Todo do something with the full image stored
// In outputfileuri. Perhaps copying it to the app folder
}
}
}
3. A compatible solution:
Public Boolean hasimagecapturebug (){
// List of known devices that have the bug
Arraylist <string> devices = new arraylist <string> ();
Devices. Add ("android-devphone1/dream_devphone/Dream ");
Devices. Add ("generic/SDK/generic ");
Devices. Add ("Vodafone/vfpioneer/Sapphire ");
Devices. Add ("tmobile/Kila/Dream ");
Devices. Add ("Verizon/voles/Sholes ");
Devices. Add ("google_ion/Sapphire ");
Return devices. Contains (Android. OS. Build. Brand + "/" + Android. OS. Build. Product + "/"
+ Android. OS. Build. Device );
}
Intent I = new intent (Android. provider. mediastore. action_image_capture );
If (hasimagecapturebug ()){
I. putextra (Android. provider. mediastore. extra_output, Uri. fromfile (new file ("/sdcard/tmp ")));
} Else {
I. putextra (Android. provider. mediastore. extra_output, Android. provider. mediastore. Images. Media. external_content_uri );
}
Startactivityforresult (I, mrequestcode );
Protected void onactivityresult (INT requestcode, int resultcode, intent ){
Switch (requestcode ){
Case globalconstants. image_capture:
Uri U;
If (hasimagecapturebug ()){
File Fi = new file ("/sdcard/tmp ");
Try {
U = URI. parse (Android. provider. mediastore. Images. Media. insertimage (getcontentresolver (), Fi. getabsolutepath (), null, null ));
If (! Fi. Delete ()){
Log. I (T, "failed to delete" + FI );
}
} Catch (filenotfoundexception e ){
E. printstacktrace ();
}
} Else {= intent. getdata ();
}
}
U
The third method can solve the version problem.
The size of a version with a bug is only 512-width.
Another drawback is that the version bug may be corrected so that your bug function needs to be modified.