当我们点击添加并按回按钮返回应用程序时,Cordova的Google AdMob插件正在关闭 [英] Google AdMob plugin for Cordova, App is closing when we are clicking on the Add and press back button to return to the App

查看:172
本文介绍了当我们点击添加并按回按钮返回应用程序时,Cordova的Google AdMob插件正在关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Cordova框架工作来构建应用程序,我使用了用于Cordova的Google AdMob插件来显示我的应用程序中的添加,而我的问题是用户点击任何添加并尝试通过单击返回到应用程序后退按钮应用程序正在关闭,用户必须从头开始,我需要做什么来解决这个问题,在此先感谢...

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 come back to the App by clicking back button the App was closing and the user has to start it from the beginning, what i need to do to over come this issue , Thanks in Advance...

推荐答案

我是admob插件的作者: https:// github。 com / floatinghotpot / cordova-admob-pro

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

您的问题与该插件无关,但与cordova默认行为无关。

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

您可以覆盖后退按钮行为,然后当用户单击后退按钮时,Cordova APP将不会退出。

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

覆盖默认值后退按钮行为,为后退按钮事件注册事件监听器,通常通过在收到设备后调用document.addEventListener真实的事件。不再需要调用任何其他方法来覆盖后退按钮行为。

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.

以下是示例javascript代码:

Here is the sample javascript code:

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

// device APIs are available
//
function onDeviceReady() {
    // Register the event listener
    document.addEventListener("backbutton", onBackKeyDown, false);
}

// Handle the back button
//
function onBackKeyDown() {
}

有关详细信息,请阅读cordova doc:
https://cordova.apache.org/docs/en/4.0.0/cordova_events_events.md.html

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

这篇关于当我们点击添加并按回按钮返回应用程序时,Cordova的Google AdMob插件正在关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆