开发者

Android Select Photo startActivityForResult always returns RESULT_CANCELED

I do this:

startActivityForResult(new In开发者_StackOverflow社区tent(Intent.ACTION_PICK,android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI), 1);

then, on onActivityResult, I ALWAYS get RESULT_CANCELED. As a matter of fact, I think onActivityResult is triggered once the photo gallery is opened up, even before the image had been selected!

Since I don't seem to find anything wrong with the code itself, is it possible I am missing something from the AndroidManifest.xml file related to the new Intent?


Try this out

Intent intent=new Intent(Intent.ACTION_PICK);
intent.setType("image/*");
startActivityForResult(intent, 111);


Intent target = new Intent(Intent.ACTION_GET_CONTENT);
target.setType("*/*");
target.addCategory(Intent.CATEGORY_OPENABLE);
Intent intent = Intent.createChooser(target, "选择打开应用");
try {
startActivityForResult(intent, 6384);
} catch (ActivityNotFoundException e) {
// The reason for the existence of aFileChooser
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜