リモートURLからビットマップを作成しようとするといくつか問題が発生します。スニペットは次のとおりです。インターネットからのアクセス許可があっても、接続からイメージを取得できない
Bitmap bm = null;
URL aURL = null;
try {
aURL = new URL("http://developer.android.com/assets/images/home/honeycomb-android.png");
} catch (MalformedURLException e) {
System.err.println(e);
}
if(aURL != null){
URLConnection conn = null;
BufferedInputStream bis = null;
InputStream is = null;
try {
conn = aURL.openConnection();
conn.connect();
is = conn.getInputStream();
bis = new BufferedInputStream(is);
bm = BitmapFactory.decodeStream(bis);
} catch (Exception e) {
System.err.println(e);
} finally {
if(bis != null){
try {
bis.close();
} catch (IOException e) {}
}
if(is != null){
try {
is.close();
} catch (IOException e) {}
}
conn = null;
}
}
conn.connect()
行に例外があります。 java.net.SocketException: Permission denied
と書かれています。
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="1"
android:versionName="1.0" package="mypackage.namehere">
<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<application android:icon="@drawable/icon" android:label="@string/app_name">
</application>
</manifest>
は、私は自分のコンピュータのブラウザとエミュレータブラウザからの両方の画像をロードすることができます。
は、私はすでにマニフェストにパーミッションを追加しました。ファイアウォールが私のインターネット接続を妨げることはありません。 複数のURLを試してみましたが、何も機能しませんでした。
正しく接続していますか?代わりにHttpConnectionを使用する必要がありますか?
あなたは一度私が好きな時に私がこの画像を見ることができるwebviewの使用で快適ですか? –
暗闇の中で撮影:マニフェストを投稿できますか? – Otra
@Otraここにあります、上記で編集しました。 –