Software Archive
Read-only legacy content
17061 Discussions

Pressing the back button on android device crash the app

dev_s_
Beginner
888 Views

Hi All,

I have an issue our QA found on android build, if the user press very fast on the back button on android the application crash.

Looking at the device log i see this error:

06-22 18:41:18.310 W/dalvikvm(23099): threadid=1: thread exiting with uncaught exception (group=0x4133d930)
06-22 18:41:18.310 E/AndroidRuntime(23099): FATAL EXCEPTION: main
06-22 18:41:18.310 E/AndroidRuntime(23099): java.lang.IllegalArgumentException: Receiver not registered: com.intel.xdk.device.Device$4@419d5638
06-22 18:41:18.310 E/AndroidRuntime(23099): at android.app.LoadedApk.forgetReceiverDispatcher(LoadedApk.java:662)
06-22 18:41:18.310 E/AndroidRuntime(23099): at android.app.ContextImpl.unregisterReceiver(ContextImpl.java:1639)
06-22 18:41:18.310 E/AndroidRuntime(23099): at android.content.ContextWrapper.unregisterReceiver(ContextWrapper.java:452)
06-22 18:41:18.310 E/AndroidRuntime(23099): at com.intel.xdk.device.Device$WebViewKeyListener.onKey(Device.java:211)
06-22 18:41:18.310 E/AndroidRuntime(23099): at android.view.View.dispatchKeyEvent(View.java:7374)
06-22 18:41:18.310 E/AndroidRuntime(23099): at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1445)
06-22 18:41:18.310 E/AndroidRuntime(23099): at android.webkit.WebView.access$701(WebView.java:264)
06-22 18:41:18.310 E/AndroidRuntime(23099): at android.webkit.WebView$PrivateAccess.super_dispatchKeyEvent(WebView.java:1903)
06-22 18:41:18.310 E/AndroidRuntime(23099): at android.webkit.WebViewClassic.dispatchKeyEvent(WebViewClassic.java:9907)
06-22 18:41:18.310 E/AndroidRuntime(23099): at android.webkit.WebView.dispatchKeyEvent(WebView.java:2227)
06-22 18:41:18.310 E/AndroidRuntime(23099): at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1450)
06-22 18:41:18.310 E/AndroidRuntime(23099): at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1450)
06-22 18:41:18.310 E/AndroidRuntime(23099): at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1450)
06-22 18:41:18.310 E/AndroidRuntime(23099): at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1450)
06-22 18:41:18.310 E/AndroidRuntime(23099): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchKeyEvent(PhoneWindow.java:2206)
06-22 18:41:18.310 E/AndroidRuntime(23099): at com.android.internal.policy.impl.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1524)
06-22 18:41:18.310 E/AndroidRuntime(23099): at android.app.Activity.dispatchKeyEvent(Activity.java:2423)
06-22 18:41:18.310 E/AndroidRuntime(23099): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:2124)
06-22 18:41:18.310 E/AndroidRuntime(23099): at android.view.ViewRootImpl.deliverKeyEventPostIme(ViewRootImpl.java:4327)
06-22 18:41:18.310 E/AndroidRuntime(23099): at android.view.ViewRootImpl.handleImeFinishedEvent(ViewRootImpl.java:4256)
06-22 18:41:18.310 E/AndroidRuntime(23099): at android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:3217)
06-22 18:41:18.310 E/AndroidRuntime(23099): at android.os.Handler.dispatchMessage(Handler.java:99)
06-22 18:41:18.310 E/AndroidRuntime(23099): at android.os.Looper.loop(Looper.java:137)
06-22 18:41:18.310 E/AndroidRuntime(23099): at android.app.ActivityThread.main(ActivityThread.java:5306)
06-22 18:41:18.310 E/AndroidRuntime(23099): at java.lang.reflect.Method.invokeNative(Native Method)
06-22 18:41:18.310 E/AndroidRuntime(23099): at java.lang.reflect.Method.invoke(Method.java:511)
06-22 18:41:18.310 E/AndroidRuntime(23099): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
06-22 18:41:18.310 E/AndroidRuntime(23099): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
06-22 18:41:18.310 E/AndroidRuntime(23099): at dalvik.system.NativeStart.main(Native Method)

 

Looking at the code in https://github.com/01org/cordova-plugin-intel-xdk-device/blob/master/src/android/Device.java i see in line 225 a call to 'unregisterReceiver' which is not wrapped in try&catch 

Any help will be appreciate.

0 Kudos
6 Replies
PaulF_IntelCorp
Employee
888 Views

Are you attempting to capture the Android backbutton in your app?

0 Kudos
dev_s_
Beginner
888 Views

No.

 

0 Kudos
PaulF_IntelCorp
Employee
888 Views

Try capturing the back button, that might help (I can't guarantee that will fix the problem, but it is certainly worth trying and will give you more control over what the backbutton does).

See this article https://cordova.apache.org/docs/en/4.0.0/cordova_events_events.md.html#backbutton and search the web for additional notes regarding this Cordova feature.

0 Kudos
dev_s_
Beginner
888 Views

I don't want to capture the back button, the default behavior is ok when pressing the button many time slow.

It's look like a bug in intel.xdk.device code, is there an option just to wrapp the 'unregisterReceiver' with try&catch just in case the calls to 'registerReceiver' and the 'unregisterReceiver' are not match.

My current solution is to remove the intel.xdk.device plugin from my project and use alternative plugins which require a lot of regression tests to my project.

0 Kudos
PaulF_IntelCorp
Employee
888 Views

That plugin has been deprecated and it is recommended that you discontinue using it in favor of the standard Cordova plugins. We have open-sourced most of the existing intel.xdk namespace plugins. You can find more info here: https://software.intel.com/en-us/xdk/docs/intel-xdk-api-cordova-plugin-methods-properties-events

You are welcome to fork that plugin and modify it for your own needs, which might get you to the unregisterReceiver method (in the native code component). The resulting modified plugin could then be imported as a local plugin into your project, but I recommend using the standard Cordova plugins, instead.

0 Kudos
dev_s_
Beginner
888 Views

According to the intel xdk IDE the intel.xdk.device plugin is not deprecated (not marked with the yellow triangle).

Anyway, thanks for your help.

 

0 Kudos
Reply