Skip to content

Instantly share code, notes, and snippets.

@macdonst
Created April 20, 2012 15:13
Show Gist options
  • Save macdonst/2429508 to your computer and use it in GitHub Desktop.
Save macdonst/2429508 to your computer and use it in GitHub Desktop.
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;
public class IMEIPlugin extends Plugin {
@Override
public PluginResult execute(String action, JSONArray args, String callbackId) {
PluginResult.Status status = PluginResult.Status.OK;
String result = "";
if (action.equals("get")) {
TelephonyManager telephonyManager =
(TelephonyManager)this.ctx.getSystemService(Context.TELEPHONY_SERVICE);
result = telephonyManager.getDeviceId();
}
else {
status = PluginResult.Status.INVALID_ACTION;
}
return new PluginResult(status, result);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment