我正在使用一个应用程序,该应用程序应该使用标准的android库显示通过HTTP定位的图像,但是图库不显示图像。
Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse(model.get_media_URL()), "image/jpeg");
startActivity(intent);
09-11 19:24:38.712: ERROR/AndroidRuntime(2939): FATAL EXCEPTION: main
09-11 19:24:38.712: ERROR/AndroidRuntime(2939): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=http://www.XXXXX.com/XXXX.jpg typ=image/jpeg }
09-11 19:24:38.712: ERROR/AndroidRuntime(2939): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1409)
09-11 19:24:38.712: ERROR/AndroidRuntime(2939): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1379)
09-11 19:24:38.712: ERROR/AndroidRuntime(2939): at android.app.Activity.startActivityFromChild(Activity.java:3067)
09-11 19:24:38.712: ERROR/AndroidRuntime(2939): at android.app.Activity.startActivityForResult(Activity.java:2847)
09-11 19:24:38.712: ERROR/AndroidRuntime(2939): at android.app.Activity.startActivity(Activity.java:2933)
09-11 19:24:38.712: ERROR/AndroidRuntime(2939): at com.treto.app.Activity_ChallengeDetailParticipations$3.onItemClick(Activity_ChallengeDetailParticipations.java:199)
09-11 19:24:38.712: ERROR/AndroidRuntime(2939): at android.widget.AdapterView.performItemClick(AdapterView.java:284)
09-11 19:24:38.712: ERROR/AndroidRuntime(2939): at android.widget.ListView.performItemClick(ListView.java:3513)
09-11 19:24:38.712: ERROR/AndroidRuntime(2939): at android.widget.AbsListView$PerformClick.run(AbsListView.java:1812)
09-11 19:24:38.712: ERROR/AndroidRuntime(2939): at android.os.Handler.handleCallback(Handler.java:587)
09-11 19:24:38.712: ERROR/AndroidRuntime(2939): at android.os.Handler.dispatchMessage(Handler.java:92)
09-11 19:24:38.712: ERROR/AndroidRuntime(2939): at android.os.Looper.loop(Looper.java:130)
09-11 19:24:38.712: ERROR/AndroidRuntime(2939): at android.app.ActivityThread.main(ActivityThread.java:3683)
09-11 19:24:38.712: ERROR/AndroidRuntime(2939): at java.lang.reflect.Method.invokeNative(Native Method)
09-11 19:24:38.712: ERROR/AndroidRuntime(2939): at java.lang.reflect.Method.invoke(Method.java:507)
09-11 19:24:38.712: ERROR/AndroidRuntime(2939): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
09-11 19:24:38.712: ERROR/AndroidRuntime(2939): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
09-11 19:24:38.712: ERROR/AndroidRuntime(2939): at dalvik.system.NativeStart.main(Native Method)
如果我使用此代码:
Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
intent.setData(Uri.parse(model.get_media_URL()));
startActivity(intent);
它可以工作,但打开互联网浏览器而不是标准图库,
谢谢!
答案 0 :(得分:0)
Intent intentBrowseFiles = new Intent(Intent.ACTION_GET_CONTENT);
intentBrowseFiles.setDataAndType(Uri.parse(model.get_media_URL()), "image/*");
intentBrowseFiles.setFlag(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intentBrowseFiles);