Tag: android

如何使用jquery以编程方式检查Internet连接的可用性

我正在开发android phonegap应用程序。当我运行没有互联网连接的应用程序时,它是强制关闭的。所以,我需要检查dom中的互联网连接,然后使用jquery / javascript调用ajax 这是我的示例代码: var a=navigator.onLine; if(a){ alert(‘online’); $.ajax({ type: “GET”, url: url, dataType: ‘json’, async: true, cache: false, success: function(data){ alert(‘success’); }, error: function(e){ alert(‘error’); } }); }else{ alert(‘ofline’); } 但即使没有互联网连接,我总是得到警报(’在线’)。请引导我。谢谢你提前

Cordova和jQuery中的错误“与服务器的连接不成功。”

我使用Cordova和JQuery mobile为Android创建了一个应用程序。 当我使用谷歌浏览器测试运行代码时,它运行良好,但当我尝试在Android模拟器上使用cmd android工作室运行它( locate>cordova emulate android )它不起作用。 当我尝试在模拟器上运行它时,我得到: “与服务器的连接不成功。(file:///android_asset/www/index.html)” 但是,如果我不使用JQuery,它可以正常工作。 我没有修改JQuery或JQuery mobile中的任何代码。 LogIn id: password: Log in 这是login.js $(document).ready(function () { $(“#let_login”).on(“tap”, function () { var id = $(“#login_id”).val(); var password = $(“#login_password”).val(); if (id == “test” && password == “password”) { document.location.href = “./customer.html”; //$.mobile.changePage(“./customer.html”); } else { $(“#wrong”).html(“Wrong id and/or password”); } […]

jquery scrollLeft无法在Android上运行

以下代码无法在Android浏览器中运行! 我如何解决它? 4545 $(‘#sannn’).bind(‘click’, function () { $(‘#sann’).scrollLeft(10); });

如何从Android移动设备键盘获取keyCodes?

目前,我在移动设备上遇到问题。 我有一个输入字段,其中只允许按下某些键:例如,只有数字0-9。 它在Web浏览器上运行得很棒。 但是当我在我的Android移动设备中打开它时,它会失败。 我用过keyup和keypress 。 keyup正在运行但我想知道哪个键从移动键盘触发了事件。 我怎么会这样?

如何在PhoneGap / Android中实现DATE PICKER?

我试图在android中实现日期选择器。 我想让它获取数据并以文本格式显示 function dateTest() { var myNewDate = new Date(); window.plugins.datePicker.show({ date : myNewDate, mode : ‘date’, // date or time or blank for both allowOldDates : true }, function(returnDate) { var newDate = new Date(returnDate); currentField.val(newDate.toString(“dd/MMM/yyyy”)); // This fixes the problem you mention at the bottom of this script with it not working a […]

从Phonegap使用ASP.NET Web服务

嗨,我一直在尝试从phonegap-android应用程序中使用ASP.NET编写的Web服务,但我似乎在某处某处犯了一个错误。 值得一提的是,当我在eclipse的android模拟器上运行它时失败了。 我已经从网络浏览器尝试了相同的代码,它工作得很好。 这是Index.html中与问题相关的部分 /* Here i declare ‘webServiceURL’ which holds the path to the service that’s hosted at 10.0.0.174 (WLAN ip of my computer). I use this instead of 127.0.0.1 because on a mobile phone localhost points to the phone itself. */ // Here i declare ‘datos’ which are the parameters sent to the […]

jQuery Mobile是否相当于Android的ViewPager?

我想使用jQuery Mobile创建水平滑动效果。 经过一些研究后,我发现ViewPager (通常位于Android Market的应用详细信息页面中) ViewPager我的需求。 在指定的页面中,作者将其与Android中的代码一起描述,但我想知道jQM中是否存在等效的插件或function。

有了Phonegap,我想录制语音,停止录制,并在Android中播放

HTML文件有4个按钮,可以录制,停止录制语音,播放,停止播放。 代码看起来像这样。 Cordova $(document).ready(function(){ $(“#record”).on(“click”, function(){ alert(“record start”); window.plugins.VoicePlugin.record(function(){alert(“yo”);}, function(){alert(“yol”);}, “voice.3gp”); }); $(“#stoprecord”).on(‘click’, function(){ alert(“record stop”); window.plugins.VoicePlugin.stoprecord(function(){}, function(){}, “voice.3pg”); }); $(“#play”).on(“click”, function(){ alert(“play”); window.plugins.VoicePlugin.play(function(){}, function(){}, “voice.3pg”); }); $(“#stopplay”).on(“click”, function(){ alert(“stop play”); window.plugins.VoicePlugin.stopplay(function(){}, function(){}, “voice.3pg”); }); }); Start Recording Stop Recording Start Playing Stop Playing Android插件部分是 package com.saxoo.voice; import java.io.IOException; import org.apache.cordova.api.Plugin; import org.apache.cordova.api.PluginResult; import org.json.JSONArray; […]

无法从第二个包含的js文件中的第一个包含的javascript文件调用函数

我正在用Apache Cordova制作一个Android应用程序。 一切都适用于默认情况下使用Chrome的Android 6.0,问题出在使用默认Android浏览器的Android 4.2.2(三星Galaxy S4 mini)上。 如果我没弄错的话,那么应用程序在使用cordova编译并安装在Android操作系统上后,在默认的Android浏览器中“启动”。 在默认的Android浏览器中,页面在加载时为空。 但在Chrome中一切正常。 问题出在默认的Android 4.2.2浏览器中。 它不适用于诺基亚1520(使用Windows Phone操作系统)的默认浏览器。 index.html的: 1.js: $(document).ready(function() { $(‘#content’).html(“test3”); // Works fine (i can see test3 on the page). showLogin(); }); 2.js(此文件中没有任何内容可用,我无法在页面上看到test1和test2): $(‘#content’).html(“test1”); function showLogin() { $(‘#content’).html(` test2 `); } 我做了什么#1 我还尝试在setTimeout()调用showLogin() setTimeout() : setTimeout(function() { showLogin(); }, 1000); 我做了什么#2 1.js: $(document).ready(function() { $(‘#content’).html(“test3”); // […]

在Android 4.0.4默认浏览器上,JavaScript点击事件无法在Samsung Galaxy SIII上运行

我对Android 4.0.4上三星Galaxy SIII的默认浏览器有一个最奇怪的问题: 在下面的页面中,单击链接不会触发JavaScript处理程序。 从其中一个div中删除单个’a’字母会使它们再次工作…… 这是JS控制台的屏幕截图: 我打开了一个android bug报告 ,如果你有同样的问题,请为它加星标,谢谢。 预先感谢您的帮助! $(document).ready(function() { alert(‘attaching click handlers’); $(“#red”).click(function(e) { alert(‘red clicked’); $(“body”).css(“background-color”, “#CC0000”); }); $(“#green”).click(function(e) { alert(‘green clicked’); $(“body”).css(“background-color”, “#00CC00”); }); $(“#blue”).click(function(e) { alert(‘blue clicked’); $(“body”).css(“background-color”, “#0000CC”); }); }); CHANGE TO RED CHANGE TO GREEN CHANGE TO BLUE Removing one of the a’s in the content below […]