Hi, I am facing problem with specific device Motorola (I have MB508), I have
a picture (picture view), on click of the picture open a gallery and select
a pic from that and set that pic on picture (picture view), however, the
below code is running fine for rest of devices. Could you please help me on
it. The code is as below.
public void Pic_Click(View v)
{
if(!isSDCARDMounted())
{
Toast.makeText(this, "Please insert SDCard first and try again.",
Toast.LENGTH_LONG).show();
return;
}
try {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT, null);
intent.setType("image/*");
intent.putExtra("crop", "true");
intent.putExtra("aspectX", aspectX);
intent.putExtra("aspectY", aspectY);
intent.putExtra("outputX", outputX);
intent.putExtra("outputY", outputY);
intent.putExtra("scale", scale);
intent.putExtra("return-data", return_data);
intent.putExtra(MediaStore.EXTRA_OUTPUT, getTempUri());
intent.putExtra("noFaceDetection",!faceDetection); // negative
boolean noFaceDetection
intent.putExtra("outputFormat",
Bitmap.CompressFormat.JPEG.toString());
if (circleCrop)
{
intent.putExtra("circleCrop", true);
}
startActivityForResult(intent, PHOTO_PICKED);
}
catch (ActivityNotFoundException e)
{
Toast.makeText(this, "We did not find a MediaStore Gallery",
Toast.LENGTH_LONG).show();
}
}
private Uri getTempUri() {
return Uri.fromFile(getTempFile());
}
private File getTempFile()
{
if (isSDCARDMounted()) {
File f = new
File(Environment.getExternalStorageDirectory(),"tempphoto.jpeg");
try {
if(!f.exists())
f.createNewFile();
} catch (IOException e)
{
// TODO Auto-generated catch block
Toast.makeText(this, "File IO issue, can\'t write temp file on
this system", Toast.LENGTH_LONG).show();
}
return f;
} else {
return null;
}
}
private boolean isSDCARDMounted(){
String status = Environment.getExternalStorageState();
if (status.equals(Environment.MEDIA_MOUNTED))
return true;
return false;
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent
data) {
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case PHOTO_PICKED:
if (resultCode == RESULT_OK) {
if (data == null) {
Log.w(TAG, "Null data, but RESULT_OK, from image picker!");
Toast t = Toast.makeText(this, "No picture
selected",Toast.LENGTH_SHORT);
t.show();
return;
final Bundle extras = data.getExtras();
if (extras != null) {
File tempFile = getTempFile();
if (data.getAction() != null) {
processPhotoUpdate(tempFile);
}
Uri selectedImage =getTempUri();//data.getData();
String imageFilePath="";
imageFilePath=selectedImage.getPath();
mImagePath=imageFilePath;
isNewPicSelect=true;
}
}
break;
}
}
The message is showing on selection "No picture selected" (No intent
available onActivityResult). Please help me on it.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en