我正在尝试运行以下代码
Uri uri = Uri.parse("URL of a photo");
ContentResolver cr = getContentResolver();
try {
InputStream fis = cr.openInputStream(uri);
// Do some stuff here ..
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
但这会引发 FileNotFoundException,我确定 URL 是正确的。是否有另一种方法可以打开 URL 的输入流?
编辑:LogCat 输出
11-06 22:05:37.939: W/System.err(20057): java.io.FileNotFoundException: No content provider: http://www.vnvlvokc.com/ow_userfiles/plugins/shoppro/images/product_1.jpg
11-06 22:05:37.939: W/System.err(20057): at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:481)
11-06 22:05:37.939: W/System.err(20057): at android.content.ContentResolver.openInputStream(ContentResolver.java:319)
11-06 22:05:37.939: W/System.err(20057): at com.example.myfacebook.Act1.post_photo(Act1.java:68)
11-06 22:05:37.939: W/System.err(20057): at com.example.myfacebook.Act1.onActivityResult(Act1.java:58)
11-06 22:05:37.939: W/System.err(20057): at android.app.Activity.dispatchActivityResult(Activity.java:3908)
11-06 22:05:37.939: W/System.err(20057): at android.app.ActivityThread.deliverResults(ActivityThread.java:2694)
11-06 22:05:37.939: W/System.err(20057): at android.app.ActivityThread.handleSendResult(ActivityThread.java:2740)
11-06 22:05:37.939: W/System.err(20057): at android.app.ActivityThread.access$2000(ActivityThread.java:121)
11-06 22:05:37.939: W/System.err(20057): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:991)
11-06 22:05:37.939: W/System.err(20057): at android.os.Handler.dispatchMessage(Handler.java:99)
11-06 22:05:37.939: W/System.err(20057): at android.os.Looper.loop(Looper.java:130)
11-06 22:05:37.939: W/System.err(20057): at android.app.ActivityThread.main(ActivityThread.java:3892)
11-06 22:05:37.949: W/System.err(20057): at java.lang.reflect.Method.invokeNative(Native Method)
11-06 22:05:37.949: W/System.err(20057): at java.lang.reflect.Method.invoke(Method.java:507)
11-06 22:05:37.949: W/System.err(20057): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
11-06 22:05:37.949: W/System.err(20057): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:642)
11-06 22:05:37.949: W/System.err(20057): at dalvik.system.NativeStart.main(Native Method)