我有 DialogFragment 类,其中我有使用图像浏览器打开新活动的按钮,
按钮代码:
Intent intent = new Intent( getActivity(), BrowsePicture.class );
intent.setType( "image/*" );
intent.setAction( Intent.ACTION_GET_CONTENT );
startActivityForResult( Intent.createChooser( intent, "Choose image" ), 1 );
这是 BrowsePicture.class:
public class BrowsePicture extends Activity {
private static final int SELECT_PICTURE = 1;
private String selectedImagePath;
private String filemanagerstring;
public static String IMAGE_NAME;
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
if (requestCode == SELECT_PICTURE) {
Uri selectedImageUri = data.getData();
Log.d("URI VAL", "selectedImageUri = " + selectedImageUri.toString());
selectedImagePath = getPath(selectedImageUri);
if(selectedImagePath!=null){
// IF LOCAL IMAGE, NO MATTER IF ITS DIRECTLY FROM GALLERY (EXCEPT PICASSA ALBUM),
// OR OI/ASTRO FILE MANAGER. EVEN DROPBOX IS SUPPORTED BY THIS BECAUSE DROPBOX DOWNLOAD THE IMAGE
// IN THIS FORM - file:///storage/emulated/0/Android/data/com.dropbox.android/...
System.out.println("local image");
}
else{
System.out.println("picasa image!");
loadPicasaImageFromGallery(selectedImageUri);
}
}
}
}
但是当我点击对话框中的按钮时,我可以看到图像浏览器,但我不能正常工作,我认为有问题:startActivityForResult(Intent.createChooser(intent, "Choose image"), 1);
提前感谢您的帮助!