Software Archive
Read-only legacy content
17061 Discussions

How to define an Application Class to override the default onCreate



I am trying to implement Parse Plugin for using Push Notification Services. Please advise me how to implement the below procedure for an Android App in Intel XDK. I tried creating a dummy plugin with an MainApplication Class and also adding the <application> tag in plugin.xml for getting included in AndroidManifest.xml, but it is not working.


Android Setup:

Phonegap/Cordova doesn't define a custom, it only defines an android Activity. With anActivity alone, we should be able to receive PNs just fine while our app is running. However, if a PN arrives when the app is not running, the app will be automatically invoked, and this plugin's ParsePushPluginReceiver runs before the Activityclass or any javascript code gets a chance to call Parse.initialize(). The result is a crash dialog. To fix this, do the following:

  1. Define a custom Application class that calls Parse.initialize() in its onCreate method. This way, the Parse subsystem gets initialized before the PN-handling code runs. Crash avoided. In your application's Java source path, e.g.,platforms/android/src/com/example/app, create a file named and define it this way

    package;  //REPLACE THIS WITH YOUR package name
    import com.parse.Parse;
    import com.parse.ParseInstallation;
    public class MainApplication extends Application {
        public void onCreate() {
            Parse.initialize(this, "YOUR_PARSE_APPID", "YOUR_PARSE_CLIENT_KEY");
  2. Now register MainApplication in AndroidManifest.xml so it's used instead of the default. In the <application> tag, add the attribute android:name="MainApplication". Obviously, you don't have to name your application class this way, but you have to use the same name in 1 and 2.


0 Kudos
1 Reply

Our support staff is not able to provide help with writing plugins. Your best bet for this sort of help would be to use the Cordova threads on StackOverflow.

0 Kudos