I have a Hybrid Remote Android App built using Mobile SDK 3.1. It is configured to use a custom community login page (it is the only entry in res/xml/servers.xml
). It's working fine, except for two issues which don't exist in the iOS version of the app:
- How do I suppress the header bar on the login page? Shown here inside the red box:
- Is there something about the login page that prevents me from loading cordova via
<script src="https://localhost/cordova.js"></script>
? This works fine in the app, but the login page reportsconnection refused
in the debugger. How can I lift this restriction? I need to use the splashscreen plugin (via javascript) once the login form is submitted to show the splash until the app is fully loaded. Again, working fine on iOS.
I suspect that the Mobile SDK handles the login page with an Android WebView which is configured to show the titlebar and to disallow localhost access, but I'm just guessing here; I know little about native Android dev and have no idea how to modify.
Best Answer
After digging around in the Salesforce MobileSDK for Android, it seems clear that both of my problems are due to design decisions within the Android version of the SDK.
For #1, suppressing the login page title bar probably could be accomplished by changing an
AndroidManifest.xml
(possibly the app's; certainly the MobileSDK plugin's), except that the code assumes that title bar is present, and causes a null pointer exception if it isn't. So you'll have to modify the code.First, update the plugin's manifest (
plugins/com.salesforce/src/android/libs/SalesforceSDK/AndroidManifest.xml
), and find:and change
android:theme
to"@android:style/Theme.Black.NoTitleBar.Fullscreen"
. Next, open:find the
onCreate
and comment out these two lines:Finally, find method
loadingLoginPage
, and replaceab.setTitle(loginUrl);
with:You'll need to rebuild the sdk;
cordova
doesn't seem to do so for me. I use the following:For #2, serving files from localhost inside the login view, it looks like the app's main web view is an instance of
SalesforceDroidGapActivity
which has support for localhost urls (viaSalesforceIceCreamWebViewClient
), but the login page is an instance ofLoginActivity
which extendsAccountAuthenticatorActivity
, and has no localhost support. Dropping in one for the other doesn't look practical either. I think the login view should have access tofile://
urls, but I'm not sure if the cordova js file and plugins would be accessible via such a file url; I'll update this post if I learn more.