뜬금없이 코드 띄웁니다..
gallery 버튼이 눌리면
ImageButton gallery = (ImageButton)findViewById(R.id.gallery_button_id);//앨범 이동 버튼
gallery.setOnClickListener(new ImageButton.OnClickListener() {
public void onClick(View v) {
Intent i = new Intent(CameraT.this, photo_Preview.class);
String imgPath = mFilename_Whole;
i.putExtra("filename", imgPath);
startActivityForResult(i, 1);
}
});
다른 액티비티
private final int imgWidth = 480;
private final int imgHeight = 800;
OnCreate에서
Intent i = getIntent();
Bundle extras = i.getExtras();
String imgPath = extras.getString("filename");
/** 완성된 이미지 보여주기 */
Log.i(imgPath, imgPath);
BitmapFactory.Options bfo = new BitmapFactory.Options();
bfo.inSampleSize = 1;
ImageView iv = (ImageView)findViewById(R.id.photo);
Bitmap bm = BitmapFactory.decodeFile(imgPath, bfo);
Bitmap resized = Bitmap.createScaledBitmap(bm, imgWidth, imgHeight, true);//로그캣에서 48번째줄이 오류원인이라고뜸
iv.setImageBitmap(resized);
처리해 줍니다. 그런데 LogCat에서 자꾸 오류가 발생하네요ㅠ
03-07 14:39:21.271: W/dalvikvm(541): threadid=1: thread exiting with uncaught exception (group=0x409951f8)
03-07 14:39:21.291: E/AndroidRuntime(541): FATAL EXCEPTION: main
03-07 14:39:21.291: E/AndroidRuntime(541): java.lang.RuntimeException: Unable to start activity ComponentInfo{kr.co.hotjellysoftware.FCFN/kr.co.hotjellysoftware.FCFN.photo_Preview}: java.lang.NullPointerException
03-07 14:39:21.291: E/AndroidRuntime(541): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1955)
03-07 14:39:21.291: E/AndroidRuntime(541): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)
03-07 14:39:21.291: E/AndroidRuntime(541): at android.app.ActivityThread.access$600(ActivityThread.java:122)
03-07 14:39:21.291: E/AndroidRuntime(541): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146)
03-07 14:39:21.291: E/AndroidRuntime(541): at android.os.Handler.dispatchMessage(Handler.java:99)
03-07 14:39:21.291: E/AndroidRuntime(541): at android.os.Looper.loop(Looper.java:137)
03-07 14:39:21.291: E/AndroidRuntime(541): at android.app.ActivityThread.main(ActivityThread.java:4340)
03-07 14:39:21.291: E/AndroidRuntime(541): at java.lang.reflect.Method.invokeNative(Native Method)
03-07 14:39:21.291: E/AndroidRuntime(541): at java.lang.reflect.Method.invoke(Method.java:511)
03-07 14:39:21.291: E/AndroidRuntime(541): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
03-07 14:39:21.291: E/AndroidRuntime(541): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
03-07 14:39:21.291: E/AndroidRuntime(541): at dalvik.system.NativeStart.main(Native Method)
03-07 14:39:21.291: E/AndroidRuntime(541): Caused by: java.lang.NullPointerException
03-07 14:39:21.291: E/AndroidRuntime(541): at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:432)
03-07 14:39:21.291: E/AndroidRuntime(541): at kr.co.hotjellysoftware.FCFN.photo_Preview.onCreate(photo_Preview.java:46)
03-07 14:39:21.291: E/AndroidRuntime(541): at android.app.Activity.performCreate(Activity.java:4465)
03-07 14:39:21.291: E/AndroidRuntime(541): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
03-07 14:39:21.291: E/AndroidRuntime(541): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1919)
03-07 14:39:21.291: E/AndroidRuntime(541): ... 11 more