手动暂停在Android的PhoneGap的应用程序 [英] Manually pause an application in Android Phonegap

查看:192
本文介绍了手动暂停在Android的PhoneGap的应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这将有可能以手动暂停一个Android应用程序的PhoneGap?我需要暂停的应用程序,并转到后台,当有人点击一个按钮。我用 navigator.app.exitApp(); 但它完全关闭应用程序。我不想关闭应用程序刚刚卸载俨然就是与本机背按钮来完成。请大家帮帮忙,谢谢。

Would it be possible to pause an Android PhoneGap application manually? I need to pause the application and go to background when somebody click a button. I used navigator.app.exitApp(); but it completely closes the application. I do not want to close the application just unload just like is done with the native back button. Please help, thanks.

推荐答案

下面是一个解决方案,它类似于约兰Teusink的答案,但更容易,因为你并不需要手动编辑Java code - 只需安装一个插件在PhoneGap的/科尔多瓦CLI。

Here's a solution which is similar to Joram Teusink's answer, but easier because you don't need to manually edit java code - just install a plugin with the phonegap / cordova CLI.

该插件一个功能:GOHOME()。如果调用此,应用程序将暂停 - 就像pressing home键。

The plugin one function: goHome(). If you call this, the app will pause - just like pressing the home button.

用法:

navigator.Backbutton.goHome(function() {
  console.log('success - the app will now pause')
}, function() {
  console.log('fail')
});

安装:

的PhoneGap本地插件添加 https://github.com/mohamed-salah/ PhoneGap的-后退按钮,plugin.git

phonegap local plugin add https://github.com/mohamed-salah/phonegap-backbutton-plugin.git

下面是GitHub的页面:

Here's the github page:

https://github.com/mohamed-salah/phonegap-backbutton- plugin.git

这篇关于手动暂停在Android的PhoneGap的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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