MainApplication Class
Every native Android app requires an instance of android.app.Application
. The MainApplication
class accomplishes these basic tasks:
- Overrides the Android
Application.onCreate()
method. - In its
onCreate()
override:- Calls the superclass
onCreate()
method. - Initializes Salesforce Mobile SDK by calling
initNative()
on the SDK manager object (MobileSyncSDKManager
). - Provides optional commented code that you can reinstate to use your app as a Salesforce identity provider.
- Provides optional commented code that you can reinstate to support push notifications.
- Calls the superclass
Here’s the entire class:
- Kotlin
- Java
Most native Android apps can use similar code. For this small amount of work, your app gets free implementations of passcode and login/logout mechanisms, plus a few other benefits. See SalesforceActivity, SalesforceListActivity, and SalesforceExpandableListActivity Classes.