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:android.net.http.cts.ApacheHttpClientTest.java
@Override protected void setUp() throws Exception { super.setUp(); mWebServer = new CtsTestServer(mContext); mWifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE); mConnectivityManager = (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE); PackageManager packageManager = mContext.getPackageManager(); mHasTelephony = packageManager.hasSystemFeature(PackageManager.FEATURE_TELEPHONY); mHasWifi = packageManager.hasSystemFeature(PackageManager.FEATURE_WIFI); }
From source file:org.apache.cordova.smsreceiver.SmsReceivingPlugin.java
@Override public boolean execute(String action, JSONArray arg1, final CallbackContext callbackContext) throws JSONException { if (action.equals(ACTION_HAS_RECEIVE_PERMISSION)) { Activity ctx = this.cordova.getActivity(); if (Build.VERSION.SDK_INT >= 23) { if (PermissionHelper.hasPermission(this, Manifest.permission.RECEIVE_SMS)) { if (ctx.getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) { callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, true)); } else { callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, false)); }//from ww w .j a v a 2s . c o m return true; } else { PermissionHelper.requestPermission(this, 0, Manifest.permission.RECEIVE_SMS); JSONObject returnObj = new JSONObject(); addProperty(returnObj, "permissionGranted", true); callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, returnObj)); return true; } } else { if (ctx.getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) { callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, true)); } else { callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, false)); } return true; } } else if (action.equals(ACTION_START_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; }
From source file:com.wolkabout.hexiwear.service.NotificationService.java
@AfterInject void setMissedCallObserver() { if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) { return;/*from w ww .j a va 2 s . c o m*/ } checkMissedCallsCount(); final ContentObserver contentObserver = new ContentObserver(new Handler()) { public void onChange(boolean selfChange) { checkMissedCallsCount(); } }; Log.i(TAG, "Observing missed calls."); contentObservers.add(contentObserver); getContentResolver().registerContentObserver(CallLog.Calls.CONTENT_URI, true, contentObserver); }
From source file:org.apache.cordova.SMSComposer.java
@Override public boolean execute(String action, JSONArray args, final CallbackContext callbackContext) throws JSONException { System.out.println("MADE IT HERE..." + action); JSONObject parameters = args.getJSONObject(0); 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 {// w w w. j ava 2 s .c o m callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, false)); } return true; } else if (action.equals(ACTION_SEND_SMS)) { System.out.println("MADE INTO HERE TOO..."); try { System.out.println(parameters.toString()); JSONArray phoneNumbers = parameters.getJSONArray("toRecipients"); System.out.println("json 1 worked"); System.out.println("1" + phoneNumbers.length()); System.out.println("2" + phoneNumbers.toString()); System.out.println("3" + phoneNumbers.get(0)); System.out.println("4" + phoneNumbers.getString(0)); String[] numbers = null; String message = parameters.getString("body"); System.out.println("json 2 worked"); System.out.println(message); if (phoneNumbers != null && phoneNumbers.length() > 0 && phoneNumbers.toString().equals("[\"\"]")) { numbers = new String[phoneNumbers.length()]; System.out.println("string array created"); for (int i = 0; i < phoneNumbers.length(); i++) { numbers[i] = phoneNumbers.getString(i); System.out.println(numbers[i]); } this.sendSMS(numbers, message); } else { this.openSMSComposer(message); // if the list is empty, open // composer instead. } callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK)); } catch (JSONException ex) { System.out.println("JSON ERRORS"); callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.ERROR, ex.getMessage())); } catch (Exception e) { System.out.println("Error handling: " + e.toString()); } return true; } System.out.println("Error with api"); callbackContext .sendPluginResult(new PluginResult(PluginResult.Status.ERROR, "Error, action doesnt fit api")); return false; }
From source file:au.com.spinninghalf.connectingtothenetwork.ActionBarTabsPager.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //getWindow().setWindowAnimations(android.R.anim.slide_in_left); //overridePendingTransition(R.anim.fadein, R.anim.fadeout); shapp = SpinningHalfApplication.getInstance(); PackageManager pm = getPackageManager(); //determine whether the device has telephony capabilities i.e. can make a phone call boolean telephonySupported = pm.hasSystemFeature(PackageManager.FEATURE_TELEPHONY); // set the result to the application variable 'hasDeviceTelephonyCapabilities'. shapp.setTelephonyCapability(telephonySupported); mViewPager = new ViewPager(this); mViewPager.setId(R.id.pager);//from w ww. j a va2s. c om setContentView(mViewPager); final ActionBar bar = getSupportActionBar(); bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); bar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE); /* BitmapDrawable bg = (BitmapDrawable)getResources().getDrawable(R.drawable.ic_action_spinning_half_tab_style); bg.setTileModeXY(TileMode.REPEAT, TileMode.REPEAT); getSupportActionBar().setBackgroundDrawable(bg); */ /* BitmapDrawable bgSplit = (BitmapDrawable)getResources().getDrawable(R.drawable.ic_action_spinning_half_tab_style); bgSplit.setTileModeXY(TileMode.REPEAT, TileMode.REPEAT); getSupportActionBar().setSplitBackgroundDrawable(bgSplit); */ mTabsAdapter = new TabsAdapter(this, mViewPager); mTabsAdapter.addTab(bar.newTab().setText("News"), NewsFragmentOne.class, null, "NEWS_TAG"); mTabsAdapter.addTab(bar.newTab().setText("Rehearsals"), RehearsalsFragmentOne.class, null, "REHEARSALS_TAG"); mTabsAdapter.addTab(bar.newTab().setText("Gig Guide"), GigListFragment.class, null, "GIG_LIST_TAG"); mTabsAdapter.addTab(bar.newTab().setText("Management"), ManagementFragmentOne.class, null, "MANAGEMENT_TAG"); mTabsAdapter.addTab(bar.newTab().setText("Services"), ServicesFragmentOne.class, null, "SERVICES_TAG"); mTabsAdapter.addTab(bar.newTab().setText("Contact"), ContactFragmentOne.class, null, "CONTACT_TAG"); if (savedInstanceState != null) { bar.setSelectedNavigationItem(savedInstanceState.getInt("tab", 0)); } }
From source file:com.nuvolect.securesuite.util.PermissionUtil.java
/** * Request permissions during application first time install. * Method will not ask for phone state if it is not a phone. * @param act/*w w w. j a v a2 s . c o m*/ */ public static void requestFirstTimePermissions(Activity act) { ArrayList<String> permissionRequests = new ArrayList<String>(); PackageManager pm = act.getPackageManager(); if (pm.hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) { if (!hasPermission(act, android.Manifest.permission.READ_PHONE_STATE)) { permissionRequests.add(Manifest.permission.READ_PHONE_STATE); } } if (!hasPermission(act, android.Manifest.permission.WRITE_EXTERNAL_STORAGE)) { permissionRequests.add(Manifest.permission.WRITE_EXTERNAL_STORAGE); } if (permissionRequests.size() > 0) { String[] requests = new String[permissionRequests.size()]; requests = permissionRequests.toArray(requests); ActivityCompat.requestPermissions(act, requests, CConst.NO_ACTION); } }
From source file:org.mitre.svmp.client.IntentHandler.java
private static int isTelephonyEnabled(Context context) { int resId = 0; TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); if (tm != null) { if (tm.getPhoneType() != TelephonyManager.PHONE_TYPE_GSM && !context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) resId = R.string.intentHandler_toast_noTelephonyCDMA; else if (tm.getSimState() != TelephonyManager.SIM_STATE_READY) resId = R.string.intentHandler_toast_noTelephonyGSM; }//from www . j av a2s. c o m return resId; }
From source file:com.fallahpoor.infocenter.fragments.SimFragment.java
private boolean isTelephonySupported() { PackageManager pm = getActivity().getPackageManager(); return pm.hasSystemFeature(PackageManager.FEATURE_TELEPHONY); }
From source file:com.wolkabout.hexiwear.service.NotificationService.java
@AfterInject void setUnreadMessageObserver() { if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) { return;//from w w w .j a v a 2 s . c om } checkUnreadMessageCount(); final ContentObserver contentObserver = new ContentObserver(new Handler()) { public void onChange(boolean selfChange) { checkUnreadMessageCount(); } }; Log.i(TAG, "Observing unread messages."); contentObservers.add(contentObserver); getContentResolver().registerContentObserver(Uri.parse("content://sms/"), true, contentObserver); }
From source file:org.cyanogenmod.theme.chooser.WallpaperAndIconPreviewFragment.java
public static ComponentName[] getIconComponents(Context context) { if (sIconComponents == null || sIconComponents.length == 0) { sIconComponents = new ComponentName[] { COMPONENT_DIALER, COMPONENT_MESSAGING, COMPONENT_CAMERA, COMPONENT_BROWSER };/*from w w w . j a v a 2s .c om*/ PackageManager pm = context.getPackageManager(); // if device does not have telephony replace dialer and mms if (!pm.hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) { sIconComponents[0] = COMPONENT_CALENDAR; sIconComponents[1] = COMPONENT_GALERY; } if (!pm.hasSystemFeature(PackageManager.FEATURE_CAMERA)) { sIconComponents[2] = COMPONENT_SETTINGS; } else { // decide on which camera icon to use try { if (pm.getPackageInfo(CAMERA_NEXT_PACKAGE, 0) != null) { sIconComponents[2] = COMPONENT_CAMERANEXT; } } catch (NameNotFoundException e) { // default to COMPONENT_CAMERA } } } return sIconComponents; }