List of usage examples for android.content.pm PackageManager FEATURE_TELEPHONY
String FEATURE_TELEPHONY
To view the source code for android.content.pm PackageManager FEATURE_TELEPHONY.
Click Source Link
From source file:Main.java
public static boolean isCallEnabled(Context context) { return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY); }
From source file:Main.java
public static boolean hasTelephony(Context context) { return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY); }
From source file:Main.java
public static boolean isDeviceSupportsSIM(Context context) { PackageManager pm = context.getPackageManager(); boolean deviceSupportsSIM = pm.hasSystemFeature(PackageManager.FEATURE_TELEPHONY); return deviceSupportsSIM; }
From source file:Main.java
public static boolean hasTelephony(Context context) { PackageManager pm = context.getPackageManager(); return pm.hasSystemFeature(PackageManager.FEATURE_TELEPHONY); }
From source file:Main.java
/** * Helper function to check if this app and device is able to make call * * @param context should be an Activity context *//*from w w w .ja v a2s .c o m*/ public static boolean isTelephonyAvailable(Context context) { return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY); }
From source file:Main.java
/** * Checks if this device supports SMS.//from www .j a va2s .c om * * @param context the Android context. * @return true if this device is SMS capable; false otherwise. */ public static boolean isSmsSupported(Context context) { PackageManager manager = context.getPackageManager(); if (manager.hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) { return true; } return false; }
From source file:Main.java
public static boolean supportSMS(Context ctx) { //Froyo or above!! TelephonyManager telephonyManager1 = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE); boolean isPhone = !(telephonyManager1.getPhoneType() == TelephonyManager.PHONE_TYPE_NONE); boolean featureTelephony = ctx.getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY); return isPhone && featureTelephony; }
From source file:com.android.contacts.activities.RequestPermissionsActivity.java
private static String[] getPermissions(PackageManager packageManager) { if (sRequiredPermissions == null) { final List<String> permissions = new ArrayList<>(); // Contacts group permissions.add(permission.GET_ACCOUNTS); permissions.add(permission.READ_CONTACTS); permissions.add(permission.WRITE_CONTACTS); if (packageManager.hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) { // Phone group // These are only used in a few places such as QuickContactActivity and // ImportExportDialogFragment. We work around missing this permission when // telephony is not available on the device (i.e. on tablets). permissions.add(permission.CALL_PHONE); permissions.add(permission.READ_CALL_LOG); permissions.add(permission.READ_PHONE_STATE); }/*w w w . j a v a 2 s.c o m*/ sRequiredPermissions = permissions.toArray(new String[0]); } return sRequiredPermissions; }
From source file:com.Trigger.SmsSendingPlugin.java
@Override public boolean execute(String action, JSONArray args, final CallbackContext callbackContext) throws JSONException { if (action.equals(ACTION_HAS_SMS_POSSIBILITY)) { Activity ctx = this.cordova.getActivity(); if (ctx.getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) { callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, true)); } else {/*from w ww .j a v a2 s . co m*/ callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, false)); } return true; } else if (action.equals(ACTION_SEND_SMS)) { try { String phoneNumber = args.getString(0); String message = args.getString(1); this.sendSMS(phoneNumber, message); callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK)); } catch (JSONException ex) { callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.ERROR, ex.getMessage())); } return true; } return false; }
From source file:org.apache.cordova.plugin.SmsInboxPlugin.java
@Override public boolean execute(String action, JSONArray arg1, final CallbackContext callbackContext) throws JSONException { if (action.equals(ACTION_HAS_SMS_POSSIBILITY)) { Activity ctx = this.cordova.getActivity(); if (ctx.getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) { callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, true)); } else {/* ww w . j a va 2s. c o m*/ callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, false)); } return true; } else if (action.equals(ACTION_RECEIVE_SMS)) { // if already receiving (this case can happen if the startReception is called // several times if (this.isReceiving) { // close the already opened callback ... PluginResult pluginResult = new PluginResult(PluginResult.Status.NO_RESULT); pluginResult.setKeepCallback(false); this.callback_receive.sendPluginResult(pluginResult); // ... before registering a new one to the sms receiver } this.isReceiving = true; if (this.smsReceiver == null) { this.smsReceiver = new SmsReceiver(); IntentFilter fp = new IntentFilter("android.provider.Telephony.SMS_RECEIVED"); fp.setPriority(1000); // fp.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY); this.cordova.getActivity().registerReceiver(this.smsReceiver, fp); } this.smsReceiver.startReceiving(callbackContext); PluginResult pluginResult = new PluginResult(PluginResult.Status.NO_RESULT); pluginResult.setKeepCallback(true); callbackContext.sendPluginResult(pluginResult); this.callback_receive = callbackContext; return true; } else if (action.equals(ACTION_STOP_RECEIVE_SMS)) { if (this.smsReceiver != null) { smsReceiver.stopReceiving(); } this.isReceiving = false; // 1. Stop the receiving context PluginResult pluginResult = new PluginResult(PluginResult.Status.NO_RESULT); pluginResult.setKeepCallback(false); this.callback_receive.sendPluginResult(pluginResult); // 2. Send result for the current context pluginResult = new PluginResult(PluginResult.Status.OK); callbackContext.sendPluginResult(pluginResult); return true; } return false; }