Skip to content

Instantly share code, notes, and snippets.

@altamic
Created September 17, 2012 13:57
Show Gist options
  • Save altamic/3737415 to your computer and use it in GitHub Desktop.
Save altamic/3737415 to your computer and use it in GitHub Desktop.
PhoneGap IMSIPlugin
package it.telecomitalia.IMSIPlugin;
import org.json.JSONArray;
import android.content.Context;
import android.telephony.TelephonyManager;
import com.phonegap.api.Plugin;
import com.phonegap.api.PluginResult;
public class IMSIPlugin 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.getSubscriberId();
}
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