1

I am working on building an mobile application on apache cordova. I am using the latest version 9.0.0 (cordova-lib@9.0.1). I have created the index.html The code works great on cordova browser. But it do not run on android device. I have not checked the emulator, because my system do not support emulators (you can say hardware acceleration fails). So I install the apk on my android phone. But the app do not work. Here is my code:-

Index.html

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet"
  href="http://code.jquery.com/mobile/1.1.1/jquery.mobile-1.1.1.min.css" />
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script
  src="http://code.jquery.com/mobile/1.1.1/jquery.mobile-1.1.1.min.js"></script>
<script src="js/swipe.js"></script>  
</head>
<body>
  <div data-role="page" id="firstpage">
    <div data-role="header">
      <h1>Swipe Left</h1>
    </div>
    <div data-role="content">
      <p>Swipe Left to get to the next page.</p>
    </div>
  </div>
  <div data-role="page" id="secondpage">
    <div data-role="header">
      <h1>Swipe Right</h1>
    </div>
    <div data-role="content">
      <p>Swipe Right to get to the next page.</p>
    </div>
  </div>

</body>
</html>

Below is my swipe.js

$(document).delegate("#firstpage", 'pageinit', function (evt) {
    $(this).bind("swipeleft", function (e) {
        $.mobile.changePage("#secondpage", {
        });
    });
})

$(document).delegate("#secondpage", 'pageinit', function (evt) {
    $(this).bind("swiperight", function (e) {
        $.mobile.changePage("#firstpage", {
        });
    });
});

Could any one would suggest how to achieve the page swipe in apache cordova.

What I want? I want to go to next page(or div) by swiping my fingers on the mobile screen.

I have done searching all the web, but the code works in browser but not on android device.

Any help would be appreciated.

Karan.T.
  • 23
  • 1
  • 6
  • 1
    How exactly does the app not work on your android device? Does it crash? Does it not look right? – Jon Jul 24 '20 at 16:35
  • It do not crash. but when i swipe left or right, nothing happens. I tried on cordova browser. when i drag mouse to left , second page is displayed. When i drag mouse to right, first page is displayed. But this do not happen when i swipe on android phone. – Karan.T. Jul 24 '20 at 16:40

1 Answers1

0

You should debug the app running on the phone with Chrome Device Inspector.

Anyway, try moving your JS and CSS resources to your local path in order to embed them with the app, probably their download is being blocked due to security policies.

andreszs
  • 2,896
  • 3
  • 26
  • 34