画像を表示しようとしていますが、表示されません:
public Bitmap getUserPic(String picID) {
String imageURL;
Bitmap bitmap = null;
Log.d("BITMAP", "Loading Picture");
imageURL = picID;
Log.d("image url", picID);
try {
bitmap = BitmapFactory.decodeStream((InputStream)new URL(imageURL).getContent());
} catch (Exception e) {
Log.d("BITMAP", "Loading Picture FAILED");
e.printStackTrace();
}
return bitmap;
}
Logcat出力:(logcat出力をきれいに表示するにはどうすればよいですか?)
10-19 17:01:50.835: D/image url(8636): http://sphotos-c.ak.fbcdn.net/hphotos-ak-prn1/c0.0.403.403/p403x403/554229_4774210003216_2100715293_n.jpg
10-19 17:01:50.840: D/BITMAP(8636): Loading Picture FAILED 10-19
17:01:50.840: W/System.err(8636): android.os.NetworkOnMainThreadException 10-19 17:01:50.840: W/System.err(8636): at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1099)
10-19 17:01:50.840: W/System.err(8636): at java.net.InetAddress.lookupHostByName(InetAddress.java:391) 10-19
17:01:50.840: W/System.err(8636): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:242) 10-19
17:01:50.840: W/System.err(8636): at java.net.InetAddress.getAllByName(InetAddress.java:220) 10-19
17:01:50.840: W/System.err(8636): at libcore.net.http.HttpConnection.<init>(HttpConnection.java:71) 10-19
17:01:50.840: W/System.err(8636): at libcore.net.http.HttpConnection.<init>(HttpConnection.java:50) 10-19
17:01:50.840: W/System.err(8636): at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:351)
10-19 17:01:50.840: W/System.err(8636): at
libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:86)
10-19 17:01:50.840: W/System.err(8636): at
libcore.net.http.HttpConnection.connect(HttpConnection.java:128) 10-19
17:01:50.840: W/System.err(8636): at
libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:308)
10-19 17:01:50.840: W/System.err(8636): at
libcore.net.http.HttpEngine.connect(HttpEngine.java:303) 10-19
17:01:50.840: W/System.err(8636): at
libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:282)
10-19 17:01:50.840: W/System.err(8636): at
libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:232) 10-19
17:01:50.840: W/System.err(8636): at
libcore.net.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:80)
10-19 17:01:50.840: W/System.err(8636): at
java.net.URLConnection.getContent(URLConnection.java:194) 10-19
17:01:50.840: W/System.err(8636): at
java.net.URL.getContent(URL.java:447) 10-19
17:01:50.840: W/System.err(8636): at jp.gr.java_conf.akabeko.testimagegallery.MainActivity.getUserPic(MainActivity.java:275)
10-19 17:01:50.845: W/System.err(8636): at jp.gr.java_conf.akabeko.testimagegallery.MainActivity$fetchArticles.onPostExecute(MainActivity.java:251)
10-19 17:01:50.845: W/System.err(8636): at jp.gr.java_conf.akabeko.testimagegallery.MainActivity$fetchArticles.onPostExecute(MainActivity.java:1)
10-19 17:01:50.845: W/System.err(8636): at android.os.AsyncTask.finish(AsyncTask.java:602) 10-19 17:01:50.845:
W/System.err(8636): at android.os.AsyncTask.access$600(AsyncTask.java:156) 10-19
17:01:50.845: W/System.err(8636): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:615)
10-19 17:01:50.845: W/System.err(8636): at android.os.Handler.dispatchMessage(Handler.java:99) 10-19
17:01:50.845: W/System.err(8636): at android.os.Looper.loop(Looper.java:137) 10-19
17:01:50.845: W/System.err(8636): at android.app.ActivityThread.main(ActivityThread.java:4517) 10-19
17:01:50.845: W/System.err(8636): at java.lang.reflect.Method.invokeNative(Native Method) 10-19
17:01:50.845: W/System.err(8636): at java.lang.reflect.Method.invoke(Method.java:511) 10-19
17:01:50.845: W/System.err(8636): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:995)
10-19 17:01:50.845: W/System.err(8636): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:762) 10-19
17:01:50.845: W/System.err(8636): at dalvik.system.NativeStart.main(Native Method) 10-19 17:01:50.915: D/CLIPBOARD(8636): Hide Clipboard dialog at Starting input: finished by someone else... !