Created
April 20, 2012 15:13
-
-
Save macdonst/2429508 to your computer and use it in GitHub Desktop.
IMEI Plugin for PhoneGap 1.4.1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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