PackageManager hasSystemFeature - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for PackageManager hasSystemFeature method.

This code example shows how to use the following methods:hasSystemFeature
        w.setMapTrackballToArrowKeys(false); // use trackball directly
        // Enable the built-in zoom 
        w.getSettings().setBuiltInZoomControls(true);
        final PackageManager pm = mContext.getPackageManager();
        boolean supportsMultiTouch =
                pm.hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH)
                || pm.hasSystemFeature(PackageManager.FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT);
        w.getSettings().setDisplayZoomControls(!supportsMultiTouch);
 
        // Add this WebView to the settings observer list and update the 
        // settings 
        final BrowserSettings s = BrowserSettings.getInstance();
        s.startManagingSettings(w.getSettings());
    } 
 
} 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:hasSystemFeature
     * @return Whether camera is available. 
     */ 
    public boolean hasCamera(Context context) {
        final PackageManager pm = context.getPackageManager();
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.GINGERBREAD) {
            return pm.hasSystemFeature(PackageManager.FEATURE_CAMERA);
        } 
 
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
            return pm.hasSystemFeature(PackageManager.FEATURE_CAMERA)
                    || pm.hasSystemFeature("android.hardware.camera.front");
        } 
 
        return pm.hasSystemFeature("android.hardware.camera.any");
    } 
 
    public String getDeviceName(Context context) {
        String manufacturer = Build.MANUFACTURER;
        String undecodedModel = Build.MODEL;
        String model = null;
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:hasSystemFeature
                js = this.fileToString("total-conversion-build.user.js", true);
            } 
        } 
 
        PackageManager pm = mContext.getPackageManager();
        boolean hasMultitouch = pm
                .hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH);
        boolean forcedZoom = sharedPref.getBoolean("pref_user_zoom", false);
        if (hasMultitouch && !forcedZoom) {
            js = js.replace("window.showZoom = true;",
                    "window.showZoom = false;"); 
        } 
 
        // hide layer chooser on desktop mode 
        // on mobile mode it is hidden via smartphone.css 
        boolean desktopMode = sharedPref.getBoolean("pref_force_desktop", false);
        if (desktopMode) {
            js = js.replace("window.showLayerChooser = true;",
                    "window.showLayerChooser = false"); 
        } 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:hasSystemFeature
		 
		@Override public int suggestSampleRate() { return sampleRate; }
		 
		static JellyBeanMR1OpenSLParameters getParameters(Context context) {
			PackageManager pm = context.getPackageManager();
			boolean lowLatency = pm.hasSystemFeature(PackageManager.FEATURE_AUDIO_LOW_LATENCY);
			AudioManager am = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
			int sr = 44100;
			int bs = 64;
			try { 
				sr = Integer.parseInt(am.getProperty(AudioManager.PROPERTY_OUTPUT_SAMPLE_RATE));
				bs = Integer.parseInt(am.getProperty(AudioManager.PROPERTY_OUTPUT_FRAMES_PER_BUFFER));
				Log.i(TAG, "sample rate: " + sr + ", buffer size: " + bs);
			} catch (Exception e) {
				Log.e(TAG, "Missing or malformed audio property: " + e.toString());
			} 
			return new JellyBeanMR1OpenSLParameters(sr, 64, 64, bs, lowLatency);
		} 
	} 
} 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:hasSystemFeature
   
  static public boolean deviceHasGPS(final Context context)
  { 
    if(hasGps_ == null) {    
      final PackageManager pm = context.getPackageManager();
      hasGps_ = pm.hasSystemFeature(PackageManager.FEATURE_LOCATION_GPS);
    } 
    return hasGps_;
  } // deviceHasGPS 
   
  static public boolean isOn(final Context context)
  { 
    final LocationManager service = (LocationManager)context.getSystemService(Context.LOCATION_SERVICE);
    return service.isProviderEnabled(LocationManager.GPS_PROVIDER);
  } // isOn 
   
  static public void showSettings(final Context context)
  { 
    final Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
    context.startActivity(intent);
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:hasSystemFeature
	 */ 
	public static boolean deviceHasCamera(Context context) {
 
		PackageManager pm = context.getPackageManager();
 
		if (pm.hasSystemFeature(PackageManager.FEATURE_CAMERA)) {
			return true; 
		} else { 
			return false; 
		} 
	} 
 
	/** 
	 * Checks that the device supports Camera supports auto focus. 
	 *  
	 * @param Context 
	 *            context - The calling activity's context. 
	 * @return boolean - True if it supports otherwise false. 
	 */ 
	public static boolean deviceCameraHasAutofocus(Context context) {
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getPackageInfo, hasSystemFeature
     */ 
    public boolean isBiometricWeakInstalled() { 
        // Check that it's installed 
        PackageManager pm = mContext.getPackageManager();
        try { 
            pm.getPackageInfo("com.android.facelock", PackageManager.GET_ACTIVITIES);
        } catch (PackageManager.NameNotFoundException e) {
            return false; 
        } 
 
        // Check that the camera is enabled 
        if (!pm.hasSystemFeature(PackageManager.FEATURE_CAMERA_FRONT)) {
            return false; 
        } 
        if (getDevicePolicyManager().getCameraDisabled(null)) {
            return false; 
        } 
 
 
        return true; 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:hasSystemFeature
	   *  
	   * @return true if google tv 
	   */ 
	  public static boolean isGoogleTV(Context context) {
	      final PackageManager pm = context.getPackageManager();
	      return pm.hasSystemFeature("com.google.android.tv");
	  } 
	   
	  public static boolean hasTelephony(Context context){
		  PackageManager pm = context.getPackageManager();
		  return pm.hasSystemFeature(PackageManager.FEATURE_TELEPHONY);
	  } 
	   
	  public static boolean isConnectedToWifi(Context context){
		  ConnectivityManager connec = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
		  NetworkInfo wifi = connec.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
		    
		  if (wifi!=null && wifi.isConnected()) {
		        return true; 
		  } else { 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:hasSystemFeature
     */ 
    public static boolean isTv(Context context) {
        if (sIsTv == null) {
            PackageManager manager = context.getPackageManager();
            if (manager != null) {
                sIsTv = manager.hasSystemFeature(PackageManager.FEATURE_TELEVISION);
                return sIsTv;
            } 
            sIsTv = false;
        } 
        return sIsTv;
    } 
 
    /** 
     * Appends the switch specifying which user agent should be used for this device. 
     * @param context The context for the caller activity. 
     */ 
    public static void addDeviceSpecificUserAgentSwitch(Context context) {
        if (isTablet(context)) {
            CommandLine.getInstance().appendSwitch(CommandLine.TABLET_UI); 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:hasSystemFeature
	 * Check if we have a barometer. Use info to disable menu items, 
	 * choose to run the service or not, etc. 
	 */ 
	private boolean hasBarometer() { 
		PackageManager packageManager = mContext.getPackageManager();
		return packageManager.hasSystemFeature(PackageManager.FEATURE_SENSOR_BAROMETER);
	} 
	 
	private void log(String message) {
		//System.out.println(message); 
		//logToFile(message); 
	} 
	 
	/**  
	 * Log data to SD card for debug purposes. 
	 * To enable logging, ensure the Manifest allows writing to SD card. 
	 *  
	 * @param text 
	 */ 
	private void logToFile(String text) {
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java

Related PackageManager hasSystemFeature Questions & Answers:

Other PackageManager hasSystemFeature Examples

22:	    // do we have a camera?
23:	    if (!getPackageManager()
24:	        .hasSystemFeature(PackageManager.FEATURE_CAMERA)) {
25:	      Toast.makeText(this, "No camera on this device", Toast.LENGTH_LONG)
26:	          .show();

Read More

86:		 * */
87:		private boolean isDeviceSupportCamera() {
88:			if (getApplicationContext().getPackageManager().hasSystemFeature(
89:					PackageManager.FEATURE_CAMERA)) {
90:				// this device has a camera

Read More

2:		 * */
3:		private boolean isDeviceSupportCamera() {
4:			if (getApplicationContext().getPackageManager().hasSystemFeature(
5:					PackageManager.FEATURE_CAMERA)) {
6:				// this device has a camera

Read More

2:			 */
3:			hasFlash = getApplicationContext().getPackageManager()
4:					.hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH);
5:	
6:			if (!hasFlash) {

Read More

hasSystemFeature Method Overview
Check whether the given feature name is one of the available features as returned by getSystemAvailableFeatures().
See Code Examples for other Android PackageManager Methods: