Created
September 17, 2012 13:57
-
-
Save altamic/3737415 to your computer and use it in GitHub Desktop.
PhoneGap IMSIPlugin
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 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