You need to sign in to do that
Don't have an account?
Extending SalesforceDroidGapActivity in SDK 2.0 breaks oAuth Logout
This weekend I upgraded from SDK 1.5.3 to 2.0. My Android hybrid app extends SalesforceDroidGapActivity (mostly to do some initialization for a custom Cordova plugin used in the app). The AndroidManifest.xml mentions my activity as the main activity instead of SalesforceDroidGapActivity.
In my app I allow customers to do an oAuth logout so they can switch orgs if necessary. In SDK 1.5.3 this was working just fine. In SDK 2.0 I am seeing exceptions (see stacktrace below for details) and the app crashes. However, if I mention SalesforceDroidGapActivity in AndroidManifest.xml instead of my derived class, oAuth Logout works just fine, and the login page comes up just fine. Of course, consequently my plugin no longer works so I need to get some resolution here.
Is deriving a subclass from SalesforceDroidGapActivity in SDK 2.0 still supported, and if yes, is there anything I need to add to the derived class to allow oAuth Logout? Note that logout reported success, the problem apparently occurs somewhere on the way to the login page.
Thanks
Peter
I/ActivityManager( 1209): START u0 {flg=0x10000000 cmp=com.betsydog.attachhub/com.salesforce.androidsdk.ui.sfhybrid.Sale
sforceDroidGapActivity} from pid 4776
D/AndroidRuntime( 4776): Shutting down VM
W/dalvikvm( 4776): threadid=1: thread exiting with uncaught exception (group=0xb4d43908)
D/dalvikvm( 4795): GC_CONCURRENT freed 283K, 15% free 2448K/2848K, paused 6ms+0ms, total 8ms
E/AndroidRuntime( 4776): FATAL EXCEPTION: main
E/AndroidRuntime( 4776): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.betsydog
.attachhub/com.salesforce.androidsdk.ui.sfhybrid.SalesforceDroidGapActivity}; have you declared this activity in your An
droidManifest.xml?
E/AndroidRuntime( 4776): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1618)
E/AndroidRuntime( 4776): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1417)
E/AndroidRuntime( 4776): at android.app.ContextImpl.startActivity(ContextImpl.java:949)
E/AndroidRuntime( 4776): at android.app.ContextImpl.startActivity(ContextImpl.java:931)
E/AndroidRuntime( 4776): at android.content.ContextWrapper.startActivity(ContextWrapper.java:284)
E/AndroidRuntime( 4776): at com.salesforce.androidsdk.app.SalesforceSDKManager.startLoginPage(SalesforceSDKManage
r.java:484)
E/AndroidRuntime( 4776): at com.salesforce.androidsdk.app.SalesforceSDKManager$1.run(SalesforceSDKManager.java:53
5)
E/AndroidRuntime( 4776): at android.accounts.AccountManager$Future2Task$1.run(AccountManager.java:1556)
E/AndroidRuntime( 4776): at android.os.Handler.handleCallback(Handler.java:725)
E/AndroidRuntime( 4776): at android.os.Handler.dispatchMessage(Handler.java:92)
E/AndroidRuntime( 4776): at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime( 4776): at android.app.ActivityThread.main(ActivityThread.java:5039)
E/AndroidRuntime( 4776): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 4776): at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime( 4776): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
E/AndroidRuntime( 4776): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
Hi Bharath, thanks for the quick response. I subclassed from SalesforceSDKManagerWithSmartStore as you suggested and this indeed resolved the problem. To allow the subclassing to work I had to modify the static init method from private to protected.
I ran into a few other compatibility problems during the upgrade from 1.5.3 to 2.0 I hope you guys could help me resolve. I will submit another post with a different topic shortly.
Thanks
Peter
All Answers
How're you initializing SalesforceSDKManager? I'm guessing you're using the initHybrid() call? In 2.0, we haven't exposed an initHybrid() call where you can pass in a subclass of SalesforceDroidGapActivity. We will include this in a future patch (safe harbor). In the meanwhile, can you try substituting SalesforceDroidGapActivity.class with your custom class? The other option is to subclass SalesforceSDKManager and create your own initHybrid(), which uses your custom class instead of SalesforceDroidGapActivity. Can you try that?
Hi Bharath, thanks for the quick response. I subclassed from SalesforceSDKManagerWithSmartStore as you suggested and this indeed resolved the problem. To allow the subclassing to work I had to modify the static init method from private to protected.
I ran into a few other compatibility problems during the upgrade from 1.5.3 to 2.0 I hope you guys could help me resolve. I will submit another post with a different topic shortly.
Thanks
Peter
Glad I could help.
We have released v2.0.2 on GitHub (v2.0.3 on npm) that addresses this issue and lets you override SalesforceDroidGapActivity and pass it in to the initHybrid() call.
Thankjs, Bharath, you guys act fast. What about SalesforceSDKManagerWithSmartStore, could you please make the same modification there since I am using the SmartStore in my application.
Peter
SalesforceSDKManagerWithSmartStore already has the required method to provide your custom subclass of SalesforceDroidGapActivity.
Hi Bharath, yes, you are correct. I must have completely overlooked that method. I just tried it and it works fine. Thanks for all your help.
Peter