Skip to content

Instantly share code, notes, and snippets.

@macdonst
macdonst / imei.js
Created April 20, 2012 15:04
IMEI Plugin for PhoneGap 1.4.1
var IMEI = function(){};
IMEI.prototype.get = function(onSuccess, onFail){
return PhoneGap.exec(onSuccess, onFail, 'IMEI', 'get', []);
};
PhoneGap.addConstructor(function(){
PhoneGap.addPlugin('imei', new IMEI());
});
@macdonst
macdonst / imei.1.5.js
Created April 20, 2012 15:07
IMEI Plugin for PhoneGap 1.5+
var IMEI = function(){};
IMEI.prototype.get = function(onSuccess, onFail){
return cordova.exec(onSuccess, onFail, 'IMEI', 'get', []);
};
cordova.addConstructor(function(){
cordova.addPlugin('imei', new IMEI());
});
@macdonst
macdonst / IMEI.java
Created April 20, 2012 15:13
IMEI Plugin for PhoneGap 1.4.1
package com.simonmacdonald.imei;
import org.json.JSONArray;
import android.content.Context;
import android.telephony.TelephonyManager;
import com.phonegap.api.Plugin;
import com.phonegap.api.PluginResult;
@macdonst
macdonst / IMEI.1.5.java
Created April 20, 2012 15:16
IMEI Plugin for PhoneGap 1.5+
package com.simonmacdonald.imei;
import org.json.JSONArray;
import android.content.Context;
import android.telephony.TelephonyManager;
import org.apache.cordova.api.Plugin;
import org.apache.cordova.api.PluginResult;
@macdonst
macdonst / ipaddress.js
Created August 22, 2012 19:02
IP Address example plugin
cordova.define("cordova/plugin/ipaddress",
function(require, exports, module) {
var exec = require("cordova/exec");
var IPAddress = function () {};
var IPAddressError = function(code, message) {
this.code = code || null;
this.message = message || '';
};
package org.apache.cordova.plugins;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.Enumeration;
import org.apache.cordova.api.Plugin;
import org.apache.cordova.api.PluginResult;
import org.json.JSONArray;
@macdonst
macdonst / ipaddress.html
Created August 22, 2012 20:40
IP Address example html
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" charset="utf-8" src="cordova.android.js"></script>
<script type="text/javascript" charset="utf-8" src="ipaddress.js"></script>
<script>
function init(){
console.log("GOT AN ONLOAD!!!")
document.addEventListener("deviceready", deviceReady, true);
}
@macdonst
macdonst / ft.js
Created October 4, 2012 17:14
FileTrasfer a bunch of files.
var remoteFiles = [];
function downloadRemotePDF() {
var local2User = JSON.parse( localStorage["locallessons"] );
$.each(local2User, function(key) {
remoteFiles.push(optionsJSON + local2User[key].idcountries + '/' + local2User[key].idcurriculum + '/' + local2User[key].idoptions + '/pdf/' + local2User[key].pdfname);
}
downloadFile();
}
@macdonst
macdonst / smsplugin.js
Created October 18, 2012 13:47
SMS Plugin JS for Cordova 2.1.0
/*
Copyright (C) 2011 by Daniel Shookowsky
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@macdonst
macdonst / create_menu.java
Created November 5, 2012 03:22
PhoneGap Android Native Menu
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.example, menu);
return true;
}