mirror of
https://github.com/apache/cordova-android.git
synced 2025-01-31 17:32:51 +08:00
start adding stuff and alerts to debug GPS, PLaySOund, and Accelerometer and PhoneGap.java corrected to match my Gap.js changes
This commit is contained in:
parent
71600b0916
commit
4cd7985448
@ -196,6 +196,7 @@ var Device = {
|
|||||||
if (Device.available || Device.whatPlatform == "Android") {
|
if (Device.available || Device.whatPlatform == "Android") {
|
||||||
try {
|
try {
|
||||||
document.location = "javascript:" + "window.DroidGap." + command + "()";
|
document.location = "javascript:" + "window.DroidGap." + command + "()";
|
||||||
|
alert('document.location=' + document.location);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
console.log("Command '" + command + "' has not been executed, because of exception: " + e);
|
console.log("Command '" + command + "' has not been executed, because of exception: " + e);
|
||||||
alert("Error executing command '" + command + "'.")
|
alert("Error executing command '" + command + "'.")
|
||||||
@ -213,11 +214,14 @@ var Device = {
|
|||||||
|
|
||||||
init: function() {
|
init: function() {
|
||||||
Device.exec("getloc");
|
Device.exec("getloc");
|
||||||
|
alert('initialized Location function and getloc was called');
|
||||||
},
|
},
|
||||||
|
|
||||||
set: function(lat, lon) {
|
set: function(lat, lon) {
|
||||||
Device.Location.lat = lat;
|
Device.Location.lat = lat;
|
||||||
Device.Location.lon = lon;
|
Device.Location.lon = lon;
|
||||||
|
alert('Device.Location let is' + lat);
|
||||||
|
alert('Device.Location lon is' + lon);
|
||||||
if(Device.Location.callback != null) {
|
if(Device.Location.callback != null) {
|
||||||
Device.Location.callback(lat, lon)
|
Device.Location.callback(lat, lon)
|
||||||
Device.Location.callback = null;
|
Device.Location.callback = null;
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
in the format of src=http://hostname:port/iBug.js
|
in the format of src=http://hostname:port/iBug.js
|
||||||
if you are not using to debug comment out
|
if you are not using to debug comment out
|
||||||
-->
|
-->
|
||||||
<script type="application/x-javascript" src="http://%(hostName)s:%(port)s/ibug.js"></script>
|
<!-- <script type="application/x-javascript" src="http://192.168.1.20:1840/ibug.js"></script> -->
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ updateAccel = function(){
|
|||||||
addLoadEvent(initGap);
|
addLoadEvent(initGap);
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</head><body orient="landscape">
|
</head><body orient="landscape">
|
||||||
<div class="toolbar">
|
<div class="toolbar">
|
||||||
<h1 id="pageTitle">Main</h1>
|
<h1 id="pageTitle">Main</h1>
|
||||||
<a style="display: none;" id="backButton" class="button" href="#"></a>
|
<a style="display: none;" id="backButton" class="button" href="#"></a>
|
||||||
|
BIN
res/raw/bird.mp3
Normal file
BIN
res/raw/bird.mp3
Normal file
Binary file not shown.
BIN
res/raw/off.mp3
Normal file
BIN
res/raw/off.mp3
Normal file
Binary file not shown.
BIN
res/raw/on.mp3
Normal file
BIN
res/raw/on.mp3
Normal file
Binary file not shown.
@ -115,7 +115,53 @@ public class PhoneGap{
|
|||||||
MediaPlayer mp = new MediaPlayer();
|
MediaPlayer mp = new MediaPlayer();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
mp.setDataSource("file:///android_asset/" + filename);
|
// MediaServer does not allow reading of urls out of app data folder
|
||||||
|
// thus we grab raw file and submit via file descriptor
|
||||||
|
// instead
|
||||||
|
// InputStream is = mCtx.getAssets().open(filename);
|
||||||
|
// work around cannot play audio streams
|
||||||
|
// to get around security restriction on MediaPlayer
|
||||||
|
// until Android sdk 1.1
|
||||||
|
// thus these changes and the playSound js
|
||||||
|
// needs moved to Dev.x so that we can if statement out
|
||||||
|
// via the sdk number
|
||||||
|
|
||||||
|
if(getSDKVersion() == "1")
|
||||||
|
{
|
||||||
|
// The hack way audio stored in R.raw.filename
|
||||||
|
// and we if statement check our way through
|
||||||
|
// to match the window.DroidGap.playSound(filename.mp3)
|
||||||
|
////call on the html side
|
||||||
|
|
||||||
|
int oursound;
|
||||||
|
|
||||||
|
if (filename == "bird.mp3") {
|
||||||
|
mp.create(mCtx, R.raw.bird);
|
||||||
|
|
||||||
|
}
|
||||||
|
if (filename == "on.mp3") {
|
||||||
|
mp.create(mCtx, R.raw.on);
|
||||||
|
}
|
||||||
|
if (filename == "off.mp3"){
|
||||||
|
mp.create(mCtx, R.raw.off);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(getSDKVersion() == "1.1")
|
||||||
|
{
|
||||||
|
//TODO: do right way here when Google fixes it
|
||||||
|
// as we have a security exception preventing
|
||||||
|
// playing audio file form file:///android_asset/ location
|
||||||
|
mp.setDataSource("file:///android_asset/" + filename);
|
||||||
|
mp.prepare();
|
||||||
|
mp.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//mp.setDataSource("file:///android_asset/" + filename);
|
||||||
|
//mp.setDataSource("http://ventrix.nsdc.gr/stuff/TERMITES_SKONH.mp3");
|
||||||
mp.prepare();
|
mp.prepare();
|
||||||
mp.start();
|
mp.start();
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
@ -142,16 +188,31 @@ public class PhoneGap{
|
|||||||
return uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getModel()
|
||||||
|
{
|
||||||
|
String model = android.os.Build.MODEL;
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
public String getProductName()
|
||||||
|
{
|
||||||
|
String productname = android.os.Build.PRODUCT;
|
||||||
|
return productname;
|
||||||
|
}
|
||||||
|
public String getOSVersion()
|
||||||
|
{
|
||||||
|
String osversion = android.os.Build.VERSION.RELEASE;
|
||||||
|
return osversion;
|
||||||
|
}
|
||||||
|
public String getSDKVersion()
|
||||||
|
{
|
||||||
|
String sdkversion = android.os.Build.VERSION.SDK;
|
||||||
|
return sdkversion;
|
||||||
|
}
|
||||||
|
|
||||||
public String getVersion()
|
public String getVersion()
|
||||||
{
|
{
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean exists()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -14,14 +14,19 @@ public final class R {
|
|||||||
public static final int icon=0x7f020000;
|
public static final int icon=0x7f020000;
|
||||||
}
|
}
|
||||||
public static final class id {
|
public static final class id {
|
||||||
public static final int appView=0x7f050000;
|
public static final int appView=0x7f060000;
|
||||||
}
|
}
|
||||||
public static final class layout {
|
public static final class layout {
|
||||||
public static final int main=0x7f030000;
|
public static final int main=0x7f030000;
|
||||||
}
|
}
|
||||||
|
public static final class raw {
|
||||||
|
public static final int bird=0x7f040000;
|
||||||
|
public static final int off=0x7f040001;
|
||||||
|
public static final int on=0x7f040002;
|
||||||
|
}
|
||||||
public static final class string {
|
public static final class string {
|
||||||
public static final int app_name=0x7f040001;
|
public static final int app_name=0x7f050001;
|
||||||
public static final int hello=0x7f040000;
|
public static final int hello=0x7f050000;
|
||||||
public static final int url=0x7f040002;
|
public static final int url=0x7f050002;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user