Skip to content Skip to sidebar Skip to footer

Google Admob Plugin For Cordova, App Is Closing When We Are Clicking On The Add And Press Back Button To Return To The App

I am using Cordova frame work to build an app,I had used Google AdMob plugin for Cordova to show the Adds in my App, and My problem is when user click on any add and tries to c

Solution 1:

Try adding following code in your Cordova Project Main Activity file after onCreate method -

@OverrideprotectedvoidonResume() {
    // TODO Auto-generated method stubsuper.onResume();
}

@OverrideprotectedvoidonPause() {
    // TODO Auto-generated method stubsuper.onPause();
}

Solution 2:

I am author of the admob plugin: https://github.com/floatinghotpot/cordova-admob-pro

Your problem is not related with the plugin, but with the cordova default behavior.

You can override the back-button behavior, then Cordova APP will not exit when user click back-button.

To override the default back-button behavior, register an event listener for the backbutton event, typically by calling document.addEventListener once you receive the deviceready event. It is no longer necessary to call any other method to override the back-button behavior.

Here is the sample javascript code:

// Wait for device API libraries to load//functiononLoad() {
    document.addEventListener("deviceready", onDeviceReady, false);
}

// device APIs are available//functiononDeviceReady() {
    // Register the event listenerdocument.addEventListener("backbutton", onBackKeyDown, false);
}

// Handle the back button//functiononBackKeyDown() {
}

For more details, read the cordova doc: https://cordova.apache.org/docs/en/4.0.0/cordova_events_events.md.html

Post a Comment for "Google Admob Plugin For Cordova, App Is Closing When We Are Clicking On The Add And Press Back Button To Return To The App"