Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Cordova to run the application in the background when you click the phone's physical return key?

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly shows you "how to use Cordova to run in the background when clicking on the physical return key of a mobile phone". The content is easy to understand and clear. I hope it can help you solve your doubts. Let me lead you to study and learn how to use Cordova to run applications in the background when clicking on the physical return key of a mobile phone.

When using Cordova to develop App, click the backkey on the phone and always return to the next level. If you want to return to the desktop directly instead of closing the program directly, you can do so!

1. Install the plug-in

First, run the following command under the project directory to add the backbutton plug-in

Cordova plugin add cordova-plugin-backbutton

two。 Examples

Call the plug-in's goHome method in the response event of the return key

Hangge.com

/ / add event listening after the page is loaded

Function onLoad () {

Document.addEventListener ("deviceready", onDeviceReady, false)

}

/ / Cordova has been loaded

Function onDeviceReady () {

/ / listen for return button events

Document.addEventListener ("backbutton", eventBackButton, false)

}

/ / return key Click response (main)

Function eventBackButton () {

/ / enter the backstage

Navigator.Backbutton.goHome (function () {

Console.log ('go home success')

}, function () {

Console.log ('go home fail')

})

}

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report