2013-04-11 6 views
0

onActivityResult에 사용자 정의 Dialoge이 있습니다. 그러나 그것은이onActivityResult 내의 사용자 정의 대화 상자에 오류가 표시됩니다.

04-11 16:40:32.141: D/dalvikvm(8897): GC_EXTERNAL_ALLOC freed 689 objects/53336 bytes in 100ms 
04-11 16:40:43.901: D/UPC Code(8897): 000014312001220 
04-11 16:40:44.001: D/AndroidRuntime(8897): Shutting down VM 
04-11 16:40:44.001: W/dalvikvm(8897): threadid=1: thread exiting with uncaught exception (group=0x40028a00) 
04-11 16:40:44.041: E/AndroidRuntime(8897): FATAL EXCEPTION: main 
04-11 16:40:44.041: E/AndroidRuntime(8897): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=195543262, result=-1, data=Intent { act=com.google.zxing.client.android.SCAN flg=0x80000 (has extras) }} to activity {com.heuristics.barcodescanner/com.heuristics.barcodescanner.MainActivity}: android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application 
04-11 16:40:44.041: E/AndroidRuntime(8897):  at android.app.ActivityThread.deliverResults(ActivityThread.java:3712) 
04-11 16:40:44.041: E/AndroidRuntime(8897):  at android.app.ActivityThread.handleSendResult(ActivityThread.java:3754) 
04-11 16:40:44.041: E/AndroidRuntime(8897):  at android.app.ActivityThread.access$2800(ActivityThread.java:135) 
04-11 16:40:44.041: E/AndroidRuntime(8897):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2162) 
04-11 16:40:44.041: E/AndroidRuntime(8897):  at android.os.Handler.dispatchMessage(Handler.java:99) 
04-11 16:40:44.041: E/AndroidRuntime(8897):  at android.os.Looper.loop(Looper.java:143) 
04-11 16:40:44.041: E/AndroidRuntime(8897):  at android.app.ActivityThread.main(ActivityThread.java:4914) 
04-11 16:40:44.041: E/AndroidRuntime(8897):  at java.lang.reflect.Method.invokeNative(Native Method) 
04-11 16:40:44.041: E/AndroidRuntime(8897):  at java.lang.reflect.Method.invoke(Method.java:521) 
04-11 16:40:44.041: E/AndroidRuntime(8897):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858) 
04-11 16:40:44.041: E/AndroidRuntime(8897):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
04-11 16:40:44.041: E/AndroidRuntime(8897):  at dalvik.system.NativeStart.main(Native Method) 
04-11 16:40:44.041: E/AndroidRuntime(8897): Caused by: android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application 
04-11 16:40:44.041: E/AndroidRuntime(8897):  at android.view.ViewRoot.setView(ViewRoot.java:513) 
04-11 16:40:44.041: E/AndroidRuntime(8897):  at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177) 
04-11 16:40:44.041: E/AndroidRuntime(8897):  at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91) 
04-11 16:40:44.041: E/AndroidRuntime(8897):  at android.app.Dialog.show(Dialog.java:241) 
04-11 16:40:44.041: E/AndroidRuntime(8897):  at com.heuristics.barcodescanner.MainActivity.onActivityResult(MainActivity.java:137) 
04-11 16:40:44.041: E/AndroidRuntime(8897):  at android.app.Activity.dispatchActivityResult(Activity.java:3931) 
04-11 16:40:44.041: E/AndroidRuntime(8897):  at android.app.ActivityThread.deliverResults(ActivityThread.java:3708) 
04-11 16:40:44.041: E/AndroidRuntime(8897):  ... 11 more 
04-11 16:40:46.191: I/Process(8897): Sending signal. PID: 8897 SIG: 9 

onActivityResult 같은 오류가 제발 도와주세요이

protected void onActivityResult(int requestCode, int resultCode, Intent data) { 
    switch(requestCode) { 
    case IntentIntegrator.REQUEST_CODE: { 
     if (resultCode != RESULT_CANCELED) { 
      IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, data); 
      if (scanResult != null) { 
       String upc = scanResult.getContents(); 

       Log.d("UPC Code",upc); 
       Product_list.add(upc); 


       final Dialog dialog = new Dialog(getApplicationContext(), android.R.style.Theme_Translucent_NoTitleBar); 
       dialog.setCancelable(false); 
       dialog.setContentView(R.layout.quantity); 
       Toast.makeText(getApplicationContext(), "DIALOGUE", Toast.LENGTH_SHORT).show(); 

       final Button navi_left; 
       Button navi_right, reset, ok; 
       final TextView quantity_text; 


       navi_left = (Button)dialog.findViewById(R.id.navi_left); 
       navi_right = (Button)dialog.findViewById(R.id.navi_right); 
       reset = (Button)dialog.findViewById(R.id.reset); 
       ok = (Button)dialog.findViewById(R.id.ok); 
       quantity_text = (TextView)dialog.findViewById(R.id.quantity_nums); 




       navi_left.setOnClickListener(new OnClickListener() { 

        @Override 
        public void onClick(View v) { 
         // TODO Auto-generated method stub 
         String pre_= quantity_text.getText().toString(); 
         int post = Integer.parseInt(pre_); 
         int post_value; 
         if(post<=0) 
         { 

          post_value = post; 
         } 
         else 
         { 
          post_value = post-1; 
         } 

        } 
       }); 

       navi_right.setOnClickListener(new OnClickListener() { 

        @Override 
        public void onClick(View v) { 
         // TODO Auto-generated method stub 
         String pre_= quantity_text.getText().toString(); 
         int post_ = Integer.parseInt(pre_)+1; 
         quantity_text.setText(post_+""); 

        } 
       }); 

       reset.setOnClickListener(new OnClickListener() { 

        @Override 
        public void onClick(View v) { 
         // TODO Auto-generated method stub 
         quantity_text.setText(0); 

        } 
       }); 

       ok.setOnClickListener(new OnClickListener() { 

        @Override 
        public void onClick(View v) { 
         // TODO Auto-generated method stub 
         dialog.dismiss(); 
         Quantity_list.add(quantity_text.getText().toString()); 
        } 
       }); 
       dialog.show(); 


       ArrayAdapter<String> my_adapter = new Custom_Adapter(getApplicationContext(), Product_list); 
       my_adapter.notifyDataSetChanged(); 
       my_list.setAdapter(my_adapter); 


      } 
     } 
     break; 
    } 
    } 
} 

처럼 보여줍니다.

답변

3

navi_left = (Button)dialog.findViewById(R.id.navi_left); 

귀하의 빠른 응답에 대한 MainActivity.this

final Dialog dialog = new Dialog(MainActivity.this, android.R.style.Theme_Translucent_NoTitleBar);   
+0

감사하십시오) (모든 버튼 및 텍스트 뷰 대신 getApplicationContext의

에 대해 동일한 작업을 수행하려고하지만, 문제는 아니다 아직 풀렸다. 질문을보십시오. 방금 편집했습니다. –

+0

업데이트를 확인하고 시도하십시오 – Raghunandan

+1

고마워요, 제 문제가 해결되었습니다. getApplicationContext()가 오류를 표시하는 이유를 설명해 주시겠습니까? –

관련 문제