2011-09-23 3 views
0

Droid Bionic, Droid 3, Motorola Photon 4g, HTC Evo 3d 및 Thunderbolt에서이 오류를 보지 못했습니다.Sprint Samsung Galaxy s2 - 활동이 유출되었습니다. IntentReceiver - unregisterReceiver()에 대한 전화가 없습니다.

다음 단계를 수행하여 "유출 IntentReceiver"오류가 발생합니다이 샘플 응용 프로그램 : 어떻게 든 스프린트 삼성 갤럭시 S2 에픽 터치 4g

  • 응용 프로그램 시작합니다 (4.52 "화면과 함께 하나) aquire

    • 을 눌러 '실행 활동 두 "버튼을
    • 열기 메뉴, 다음 하위 메뉴 (음식)를 엽니 다 - 참고 : 당신은 옵션을 클릭 할 필요가 없습니다, 단순히 하위 메뉴를보기에 충분하다
    • 휴대폰의 뒤로 버튼을 누르면 하위 메뉴와 메뉴가 닫힙니다.
    • ActivityOne로 돌아가려면 휴대폰의 뒤로 버튼을 누릅니다. eclipse는 아래 오류를 인쇄합니다.

    메뉴를 열고 하위 메뉴가 아닌 단일 옵션 항목을 선택한 다음 뒤로 버튼을 누르면 오류가 표시되지 않습니다.

    내 질문은 :이 등록 된 IntentReceiver는 어디에서 왔으며 어떻게 등록을 취소 할 수 있습니까?

    감사합니다.

    # AndroidManifest.xml (Target version is 2.3.3) 
    
    <?xml version="1.0" encoding="utf-8"?> 
    <manifest xmlns:android="http://schemas.android.com/apk/res/android" 
        package="com.test" android:versionCode="1" android:versionName="1.0"> 
        <uses-sdk android:minSdkVersion="10" /> 
        <application android:icon="@drawable/icon" android:label="@string/app_name"> 
         <activity android:name=".ActivityOne" android:label="@string/app_name"> 
          <intent-filter> 
           <action android:name="android.intent.action.MAIN" /> 
           <category android:name="android.intent.category.LAUNCHER" /> 
          </intent-filter> 
         </activity> 
         <activity android:name=".ActivityTwo"></activity> 
        </application> 
    </manifest> 
    
    
    # one.xml (layout for ActivityOne) 
    
    <?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="Hello this is activity one" /> 
        <Button android:layout_width="wrap_content" 
         android:layout_height="wrap_content" android:id="@+id/launch_activity_two" 
         android:text="Launch Activity Two" /> 
    </LinearLayout> 
    
    
    # two.xml (layout for ActivityTwo) 
    
    <?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="Hello this is activity Two. The only way to leave is by pressing the back button on your phone. If you open a submenu (press menu button then select a submenu) - then press the back button on your phone there will be an exception thrown." /> 
    </LinearLayout> 
    
    
    # menu/menu.xml 
    
    <?xml version="1.0" encoding="utf-8"?> 
    <menu xmlns:android="http://schemas.android.com/apk/res/android"> 
        <item android:id="@+id/food" android:title="Food"> 
         <menu> 
          <item android:id="@+id/food_is_good" android:title="Food is good" /> 
          <item android:id="@+id/food_is_delicious" android:title="Food is delicious" /> 
          <item android:id="@+id/food_is_bad" android:title="Food is bad" /> 
         </menu> 
        </item> 
        <item android:id="@+id/doggies_are_cuddly" android:title="Doggies are cuddly" /> 
    </menu> 
    
    
    # ActivityOne 
    
    public class ActivityOne extends Activity { 
        /** Called when the activity is first created. */ 
        @Override 
        public void onCreate(Bundle savedInstanceState) { 
         super.onCreate(savedInstanceState); 
         setContentView(R.layout.one); 
    
         // launches activity two 
         Button button = (Button)findViewById(R.id.launch_activity_two); 
         button.setOnClickListener(new View.OnClickListener() { 
          @Override 
          public void onClick(View v) { 
           Intent intent = new Intent(getApplicationContext(), ActivityTwo.class); 
           startActivity(intent);    
          } 
         }); 
    
         Log.v("Samsung Galaxy sII", "Created Activity One"); 
        } 
    } 
    
    
    # ActivityTwo 
    
    public class ActivityTwo extends Activity { 
    
        /** Called when the activity is first created. */ 
        @Override 
        public void onCreate(Bundle savedInstanceState) { 
         super.onCreate(savedInstanceState); 
         setContentView(R.layout.two); 
         Log.v("Samsung Galaxy sII", "Created Activity Two"); 
        } 
    
        @Override 
        public boolean onCreateOptionsMenu(Menu menu) { 
         Log.v("Samsung Galaxy sII", "Creating options menu"); 
         MenuInflater inflater = getMenuInflater(); 
         inflater.inflate(R.menu.menu, menu); 
         return super.onCreateOptionsMenu(menu); 
        } 
    
        @Override 
        public boolean onOptionsItemSelected(MenuItem item) { 
         // Handle item selection 
         switch (item.getItemId()) { 
         case R.id.food_is_bad: 
          Log.v("Samsung Galaxy sII", "Food is bad"); 
          return true; 
         case R.id.food_is_good: 
          Log.v("Samsung Galaxy sII", "Food is good"); 
          return true; 
         case R.id.food_is_delicious: 
          Log.v("Samsung Galaxy sII", "Food is delicious"); 
          return true; 
         case R.id.doggies_are_cuddly: 
          Log.v("Samsung Galaxy sII", "Doggies are cuddly"); 
          return true; 
         default: 
          return super.onOptionsItemSelected(item); 
         } 
        } 
    } 
    
    
    
    09-23 00:46:09.210: VERBOSE/Samsung Galaxy sII(28668): Created Activity Two 
    09-23 00:46:11.791: VERBOSE/Samsung Galaxy sII(28668): Created Activity Two 
    09-23 00:46:12.705: VERBOSE/Samsung Galaxy sII(28668): Creating options menu 
    09-23 00:46:19.120: ERROR/ActivityThread(28668): Activity com.test.ActivityTwo has leaked IntentReceiver [email protected] that was originally registered here. Are you missing a call to unregisterReceiver()? 
    09-23 00:46:19.120: ERROR/ActivityThread(28668): android.app.IntentReceiverLeaked: Activity com.test.ActivityTwo has leaked IntentReceiver [email protected] that was originally registered here. Are you missing a call to unregisterReceiver()? 
    09-23 00:46:19.120: ERROR/ActivityThread(28668):  at android.app.LoadedApk$ReceiverDispatcher.<init>(LoadedApk.java:756) 
    09-23 00:46:19.120: ERROR/ActivityThread(28668):  at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:551) 
    09-23 00:46:19.120: ERROR/ActivityThread(28668):  at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:858) 
    09-23 00:46:19.120: ERROR/ActivityThread(28668):  at android.app.ContextImpl.registerReceiver(ContextImpl.java:845) 
    09-23 00:46:19.120: ERROR/ActivityThread(28668):  at android.app.ContextImpl.registerReceiver(ContextImpl.java:839) 
    09-23 00:46:19.120: ERROR/ActivityThread(28668):  at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:318) 
    09-23 00:46:19.120: ERROR/ActivityThread(28668):  at com.android.internal.view.menu.MenuDialogHelper.show(MenuDialogHelper.java:97) 
    09-23 00:46:19.120: ERROR/ActivityThread(28668):  at com.android.internal.policy.impl.PhoneWindow.onSubMenuSelected(PhoneWindow.java:808) 
    09-23 00:46:19.120: ERROR/ActivityThread(28668):  at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:867) 
    09-23 00:46:19.120: ERROR/ActivityThread(28668):  at com.android.internal.view.menu.IconMenuView.invokeItem(IconMenuView.java:532) 
    09-23 00:46:19.120: ERROR/ActivityThread(28668):  at com.android.internal.view.menu.IconMenuItemView.performClick(IconMenuItemView.java:122) 
    09-23 00:46:19.120: ERROR/ActivityThread(28668):  at android.view.View$PerformClick.run(View.java:9238) 
    09-23 00:46:19.120: ERROR/ActivityThread(28668):  at android.os.Handler.handleCallback(Handler.java:587) 
    09-23 00:46:19.120: ERROR/ActivityThread(28668):  at android.os.Handler.dispatchMessage(Handler.java:92) 
    09-23 00:46:19.120: ERROR/ActivityThread(28668):  at android.os.Looper.loop(Looper.java:130) 
    09-23 00:46:19.120: ERROR/ActivityThread(28668):  at android.app.ActivityThread.main(ActivityThread.java:3691) 
    09-23 00:46:19.120: ERROR/ActivityThread(28668):  at java.lang.reflect.Method.invokeNative(Native Method) 
    09-23 00:46:19.120: ERROR/ActivityThread(28668):  at java.lang.reflect.Method.invoke(Method.java:507) 
    09-23 00:46:19.120: ERROR/ActivityThread(28668):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907) 
    09-23 00:46:19.120: ERROR/ActivityThread(28668):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:665) 
    09-23 00:46:19.120: ERROR/ActivityThread(28668):  at dalvik.system.NativeStart.main(Native Method) 
    
  • 답변

    0

    onCreateOptionsMenu(Menu menu)은 옵션 메뉴가 표시 될 때마다 호출됩니다. 나는 이것과 함께 몇 가지 이상한 효과를 보았고 지금은 onPrepareOptionsMenu(Menu menu)을 사용했다. 단지 활동에 대해 한 번만 호출했기 때문에이 문제를 해결하는 데 도움이된다.

    S2에 설치된 Android 버전이 하위 메뉴에 대한 메소드를 다시 호출하고이 과정을 통해 등록 된 IntentReceiver를 누설했을 수 있습니다.이 경우 메뉴가 두 번 생성됩니다.

    0

    메뉴에 오류가 없는지 확인하십시오. SG2에서이 오류를 가져 오는 방법은 여러 가지가 있습니다. 종종 여러 장치에서 무시 되더라도 오류는 정확합니다. 전반적으로, 메뉴 핸들링에서 메뉴를 정상적으로 처리하는 무언가를하면이 오류가 발생합니다. 하위 메뉴가있는 항목에 대해 onOptionsItemSelected에서 활동 시작.

    관련 문제