java code 입니다 ==============
package down.image;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.widget.ImageView;
public class image extends Activity {
/** Called when the activity is first created. */
private final String URLPATH = "http://imgnews.naver.com/image/032/2010/11/24/3.jpg";
ImageView imgView;
Bitmap bm;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
try {
URL url = new URL(URLPATH);
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
conn.setDoInput(true);
conn.connect();
int length = conn.getContentLength(); // 받아온 컨텐츠의 길이를 length 변수에 저장합니다.
InputStream is = conn.getInputStream(); // InputStream is 변수에 받아온 InputStream을 저장합니다.
bm = BitmapFactory.decodeStream(is); // 받아온 이미지를 bmImg에 넣어둡니다.
is.close();
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
imgView = (ImageView) findViewById(R.id.view);
imgView.setImageBitmap(bm);
}
}
xml 코드입니다==========
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<ImageView android:id="@+id/view"
android:layout_width="fill_parent"
android:layout_height = "fill_parent"
android:layout_gravity="center"/>
</LinearLayout>
메니페스토 입니다 ============
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="down.image"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".image"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission>
<uses-permission android:name="android.permission.READ_PHONE_STATE"></uses-permission>
</manifest>
INTERNET Permission 해줫구요.
wifi도 켜놨습니다.
위 코드는 인터넷 상에 떠도는 코드를 베겨서 조큼 손 본 거구요.
그 이유도 인터넷 에 떠도는 코드대로 해도 이미지가 보이지 않았기 때문입니다.
WHY ???? WHY??? WHWHWHWHY????????????
소스 대로 했는데 이미지가 뜨지 않는 걸까요?
정말, 당췌 , 도저히 이유를 모르겟습니다.
심지어 에러가 나오지 않습니다.............
But, 한가지 bitmap decode 할 때 null이 반환 되긴 하네요.
왜 그런가요 -_-??





자답 -!
코드에 이상이 없습니다.
wifi 를 nespot으로 설정 해 놨었는데
id password를 입력안해서 인터넷이 안 된 것이 더군요! :P