마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

4.4.2 카메라 Unable to resume activity

+1 추천

현재 갤럭시 s3(4.1.2) 노트2 (4.4.2) 로 테스트중입니다. 최신폰 몇개 빌려 해보았는데 모두 정상적으로 되는데

 

유독 노트2 (4.4.2)에서 문제가 발생되고있습니다. 

 

재현 상황은 카메라로 사진을 찍은뒤 미리보기에서 저장버튼을 눌러 file 을 bitmap 으로 디코드 할 때 발생합니다. 

 

=====================================

코드입니다.

private Bitmap loadImageWithSampleSize(File file) {
    BitmapFactory.Options options = new BitmapFactory.Options();
    options.inJustDecodeBounds = true;
    BitmapFactory.decodeFile(file.getAbsolutePath(), options);

    int sampleSize = 1;
    sampleSize = calculateInSampleSize(options, 100, 100);
    options.inJustDecodeBounds = false;
    options.inSampleSize = sampleSize;
    Bitmap bitmap = BitmapFactory.decodeFile(file.getAbsolutePath(), options);

    return bitmap;
}

public static int calculateInSampleSize(
        BitmapFactory.Options options, int reqWidth, int reqHeight) {
    // Raw height and width of image
    final int height = options.outHeight;
    final int width = options.outWidth;
    int inSampleSize = 1;

    if (height > reqHeight || width > reqWidth) {

        // Calculate ratios of height and width to requested height and width
        final int heightRatio = Math.round((float) height / (float) reqHeight);
        final int widthRatio = Math.round((float) width / (float) reqWidth);

        // Choose the smallest ratio as inSampleSize value, this will guarantee
        // a final image with both dimensions larger than or equal to the
        // requested height and width.
        inSampleSize = heightRatio < widthRatio ? heightRatio : widthRatio;
    }

    return inSampleSize;
}
============================================

==================================================

에러 내용

 

Unable to resume activity {}: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=200, result=-1, data=null} to activity {}: java.lang.NullPointerException

        at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3076)

        at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3105)

        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)

        at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:4054)

        at android.app.ActivityThread.access$1000(ActivityThread.java:175)

        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1314)

        at android.os.Handler.dispatchMessage(Handler.java:102)

        at android.os.Looper.loop(Looper.java:146)

 

============================================

 

위 에러가 뜨며 bitmap 이 null 이여서 앱이 죽고있습니다.

 

간헐적인 발생이며 10번 시도하면 8번은 앱이 죽습니다. 어쩔땐 이상하게 잘되구요...
 
물론 다른 폰에서 다 잘됩니다. 갤럭시 노트2에서만 죽습니다.
 
sampleSize 를 4로 넣었떠니 노트2는 잘되더니 다른폰이 죽더라구요 
 
위 코드로 하면 다른폰은 다 잘되고 노트2만 죽고요...
 
아래 코드로 하니 앱은 모두 안죽지만 디코드하는데 폰마다 차이가 있지만 10초정도 걸리는듯 하더라구요...
 
어떻게 해결해야 할까요 ㅠㅠ 폰이 이상한가 싶어 공장초기화까지 해보고 별짓 다하고 있는데 안되고 있어
 
여기까지 와 질문 남기게 되었습니다 고수님들 도와주세요 
 
긴글 읽어주셔 감사합니다.
 
 
BitmapFactory.Options options = new BitmapFactory.Options(); options.inPreferredConfig = Bitmap.Config.ARGB_8888; Bitmap bitmap = BitmapFactory.decodeFile(photoPath, options);
익명사용자 님이 2018년 11월 27일 질문

답변 달기

· 글에 소스 코드 보기 좋게 넣는 법
· 질문에 대해 추가적인 질문이나 의견이 있으면 답변이 아니라 댓글로 달아주시기 바랍니다.
표시할 이름 (옵션):
개인정보: 당신의 이메일은 이 알림을 보내는데만 사용됩니다.
스팸 차단 검사:
스팸 검사를 다시 받지 않으려면 로그인하거나 혹은 가입 하세요.
...