Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change registerReceiver to be a BroadcastReceiver #5

Open
ghost opened this issue Mar 4, 2014 · 3 comments
Open

change registerReceiver to be a BroadcastReceiver #5

ghost opened this issue Mar 4, 2014 · 3 comments
Labels

Comments

@ghost
Copy link

ghost commented Mar 4, 2014

Seems like conditionally unregistering on checking the Intent return value for being null is not the right move here. The real fix is fixing the permissions.

03-03 20:30:04.361: E/ActivityThread(4677): Activity com.codepath.caltraindating.MainActivity has leaked IntentReceiver com.codepath.caltraindating.MainActivity$1@52777330 that was originally registered here. Are you missing a call to unregisterReceiver()?
03-03 20:30:04.361: E/ActivityThread(4677): android.app.IntentReceiverLeaked: Activity com.codepath.caltraindating.MainActivity has leaked IntentReceiver com.codepath.caltraindating.MainActivity$1@52777330 that was originally registered here. Are you missing a call to unregisterReceiver()?
03-03 20:30:04.361: E/ActivityThread(4677):     at android.app.LoadedApk$ReceiverDispatcher.<init>(LoadedApk.java:800)
03-03 20:30:04.361: E/ActivityThread(4677):     at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:601)
03-03 20:30:04.361: E/ActivityThread(4677):     at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1349)
03-03 20:30:04.361: E/ActivityThread(4677):     at android.app.ContextImpl.registerReceiver(ContextImpl.java:1329)
03-03 20:30:04.361: E/ActivityThread(4677):     at android.app.ContextImpl.registerReceiver(ContextImpl.java:1323)
03-03 20:30:04.361: E/ActivityThread(4677):     at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:446)
03-03 20:30:04.361: E/ActivityThread(4677):     at com.codepath.caltraindating.MainActivity.onCreate(MainActivity.java:110)
03-03 20:30:04.361: E/ActivityThread(4677):     at android.app.Activity.performCreate(Activity.java:5133)
03-03 20:30:04.361: E/ActivityThread(4677):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
03-03 20:30:04.361: E/ActivityThread(4677):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
03-03 20:30:04.361: E/ActivityThread(4677):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
03-03 20:30:04.361: E/ActivityThread(4677):     at android.app.ActivityThread.access$600(ActivityThread.java:141)
03-03 20:30:04.361: E/ActivityThread(4677):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
03-03 20:30:04.361: E/ActivityThread(4677):     at android.os.Handler.dispatchMessage(Handler.java:99)
03-03 20:30:04.361: E/ActivityThread(4677):     at android.os.Looper.loop(Looper.java:137)
03-03 20:30:04.361: E/ActivityThread(4677):     at android.app.ActivityThread.main(ActivityThread.java:5103)
03-03 20:30:04.361: E/ActivityThread(4677):     at java.lang.reflect.Method.invokeNative(Native Method)
03-03 20:30:04.361: E/ActivityThread(4677):     at java.lang.reflect.Method.invoke(Method.java:525)
03-03 20:30:04.361: E/ActivityThread(4677):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
03-03 20:30:04.361: E/ActivityThread(4677):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
03-03 20:30:04.361: E/ActivityThread(4677):     at dalvik.system.NativeStart.main(Native Method)

@dangilk @tristan-meng

@erg
Copy link
Owner

erg commented Mar 4, 2014

Reverted my last patch, still broken:

03-03 21:40:31.381: E/AndroidRuntime(22974): FATAL EXCEPTION: main
03-03 21:40:31.381: E/AndroidRuntime(22974): java.lang.RuntimeException: Unable to stop activity {com.codepath.caltraindating/com.codepath.caltraindating.MainActivity}: java.lang.IllegalArgumentException: Receiver not registered: com.codepath.caltraindating.MainActivity$1@42d71130
03-03 21:40:31.381: E/AndroidRuntime(22974):    at android.app.ActivityThread.performStopActivityInner(ActivityThread.java:3323)
03-03 21:40:31.381: E/AndroidRuntime(22974):    at android.app.ActivityThread.handleStopActivity(ActivityThread.java:3369)
03-03 21:40:31.381: E/AndroidRuntime(22974):    at android.app.ActivityThread.access$1000(ActivityThread.java:159)
03-03 21:40:31.381: E/AndroidRuntime(22974):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1343)
03-03 21:40:31.381: E/AndroidRuntime(22974):    at android.os.Handler.dispatchMessage(Handler.java:99)
03-03 21:40:31.381: E/AndroidRuntime(22974):    at android.os.Looper.loop(Looper.java:137)
03-03 21:40:31.381: E/AndroidRuntime(22974):    at android.app.ActivityThread.main(ActivityThread.java:5419)
03-03 21:40:31.381: E/AndroidRuntime(22974):    at java.lang.reflect.Method.invokeNative(Native Method)
03-03 21:40:31.381: E/AndroidRuntime(22974):    at java.lang.reflect.Method.invoke(Method.java:525)
03-03 21:40:31.381: E/AndroidRuntime(22974):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1187)
03-03 21:40:31.381: E/AndroidRuntime(22974):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
03-03 21:40:31.381: E/AndroidRuntime(22974):    at dalvik.system.NativeStart.main(Native Method)
03-03 21:40:31.381: E/AndroidRuntime(22974): Caused by: java.lang.IllegalArgumentException: Receiver not registered: com.codepath.caltraindating.MainActivity$1@42d71130
03-03 21:40:31.381: E/AndroidRuntime(22974):    at android.app.LoadedApk.forgetReceiverDispatcher(LoadedApk.java:667)
03-03 21:40:31.381: E/AndroidRuntime(22974):    at android.app.ContextImpl.unregisterReceiver(ContextImpl.java:1728)
03-03 21:40:31.381: E/AndroidRuntime(22974):    at android.content.ContextWrapper.unregisterReceiver(ContextWrapper.java:475)
03-03 21:40:31.381: E/AndroidRuntime(22974):    at com.codepath.caltraindating.MainActivity.onStop(MainActivity.java:278)
03-03 21:40:31.381: E/AndroidRuntime(22974):    at android.app.Instrumentation.callActivityOnStop(Instrumentation.java:1229)
03-03 21:40:31.381: E/AndroidRuntime(22974):    at android.app.Activity.performStop(Activity.java:5516)
03-03 21:40:31.381: E/AndroidRuntime(22974):    at android.app.ActivityThread.performStopActivityInner(ActivityThread.java:3320)
03-03 21:40:31.381: E/AndroidRuntime(22974):    ... 11 more

@erg
Copy link
Owner

erg commented Mar 4, 2014

If we add a logout feature, we can programatically disable a broadcast receiver while the app is logged out:

http://stackoverflow.com/questions/4805269/programmatically-register-a-broadcast-receiver

@erg erg added the crash label Mar 5, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant