Example usage for android.content.pm PackageManager hasSystemFeature

List of usage examples for android.content.pm PackageManager hasSystemFeature

Introduction

In this page you can find the example usage for android.content.pm PackageManager hasSystemFeature.

Prototype

public abstract boolean hasSystemFeature(String name);

Source Link

Document

Check whether the given feature name is one of the available features as returned by #getSystemAvailableFeatures() .

Usage

From source file:org.protocoderrunner.apprunner.api.PDevice.java

@ProtoMethod(description = "Check if the device has gyroscope", example = "")
public boolean hasGyroscope() {
    PackageManager pm = getContext().getPackageManager();
    return pm.hasSystemFeature(PackageManager.FEATURE_SENSOR_GYROSCOPE);
}

From source file:org.protocoderrunner.apprunner.api.PDevice.java

@ProtoMethod(description = "Check if the device has GPS", example = "")
public boolean hasGPS() {
    PackageManager pm = getContext().getPackageManager();
    return pm.hasSystemFeature(PackageManager.FEATURE_LOCATION_GPS);
}

From source file:org.protocoderrunner.apprunner.api.PDevice.java

@ProtoMethod(description = "Check if the device has light sensor", example = "")
public boolean hasLightSensor() {
    PackageManager pm = getContext().getPackageManager();
    return pm.hasSystemFeature(PackageManager.FEATURE_SENSOR_LIGHT);
}

From source file:org.protocoderrunner.apprunner.api.PDevice.java

@ProtoMethod(description = "Check if the device has proximity sensor", example = "")
public boolean hasProximitySensor() {
    PackageManager pm = getContext().getPackageManager();
    return pm.hasSystemFeature(PackageManager.FEATURE_SENSOR_PROXIMITY);
}

From source file:org.protocoderrunner.apprunner.api.PDevice.java

@ProtoMethod(description = "Check if the device has step detector", example = "")
public boolean hasStepDetector() {
    PackageManager pm = getContext().getPackageManager();
    return pm.hasSystemFeature(PackageManager.FEATURE_SENSOR_STEP_DETECTOR);
}

From source file:org.protocoderrunner.apprunner.api.PDevice.java

@ProtoMethod(description = "Check if the device has barometer", example = "")
public boolean hasBarometer() {
    PackageManager pm = getContext().getPackageManager();
    return pm.hasSystemFeature(PackageManager.FEATURE_SENSOR_BAROMETER);
}

From source file:com.intel.xdk.camera.Camera.java

public synchronized void takePicture(final int quality, final String saveToLibYN, final String picType) {
    //saveToLibYN is not used because the camera activity always saves to gallery

    PackageManager pm = activity.getPackageManager();
    if (pm.hasSystemFeature(PackageManager.FEATURE_CAMERA) == false) {
        fireJSEvent("camera.picture.add", false, null,
                new String[] { String.format("ev.error='device has no camera';") });
    }// w  w  w . j  ava 2s . co m

    if (busy) {
        cameraBusy();
    }
    this.busy = true;

    File outputFile = new File(Environment.getExternalStorageDirectory(), "test." + picType);

    //put required info in shared prefs
    SharedPreferences.Editor prefsEditor = activity.getSharedPreferences(cameraPrefsKey, 0).edit();
    prefsEditor.putString(cameraPrefsFileName, outputFile.getAbsolutePath());
    prefsEditor.putBoolean(cameraPrefsIsPNG, "png".equalsIgnoreCase(picType));
    prefsEditor.putInt(cameraPrefsQuality, quality);
    prefsEditor.commit();

    Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(outputFile));

    //cordova.setActivityResultCallback(this);
    // TODO: figure this out
    cordova.startActivityForResult(this, intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);
    //activity.setLaunchedChildActivity(true);
    //activity.startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);
}

From source file:com.paramedic.mobshaman.fragments.AccionesDetalleServicioFragment.java

/**
 * Start the camera by dispatching a camera intent.
 *//*from  www  .  ja v  a 2s.  c o m*/
protected void dispatchTakePictureIntent(boolean isFinishingService) {

    // Check if there is a camera.
    Context context = getActivity();
    PackageManager packageManager = context.getPackageManager();
    if (packageManager.hasSystemFeature(PackageManager.FEATURE_CAMERA) == false) {
        Toast.makeText(getActivity(), "This device does not have a camera.", Toast.LENGTH_SHORT).show();
        return;
    }

    // Camera exists? Then proceed...
    Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);

    // Ensure that there's a camera activity to handle the intent
    DetalleServicioActivity activity = (DetalleServicioActivity) getActivity();
    if (takePictureIntent.resolveActivity(activity.getPackageManager()) != null) {
        // Create the File where the photo should go.
        // If you don't do this, you may get a crash in some devices.
        File photoFile = null;
        try {
            photoFile = createImageFile();
        } catch (IOException ex) {
            // Error occurred while creating the File
            Toast toast = Toast.makeText(activity, "There was a problem saving the photo...",
                    Toast.LENGTH_SHORT);
            toast.show();
        }
        // Continue only if the File was successfully created
        if (photoFile != null) {
            Uri fileUri = Uri.fromFile(photoFile);
            activity.setCapturedImageURI(fileUri);
            activity.setCurrentPhotoPath(fileUri.getPath());
            activity.setIsFinishingService(isFinishingService);
            takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, activity.getCapturedImageURI());

            startActivityForResult(takePictureIntent, REQUEST_TAKE_PHOTO);
        }
    }
}

From source file:com.nadmm.airports.FragmentBase.java

protected void makeClickToCall(TextView tv) {
    PackageManager pm = mActivity.getPackageManager();
    boolean hasTelephony = pm.hasSystemFeature(PackageManager.FEATURE_TELEPHONY);
    if (hasTelephony && tv.getText().length() > 0) {
        UiUtils.setTextViewDrawable(tv, R.drawable.ic_phone);
        tv.setTag(Intent.ACTION_DIAL);/*from ww  w  . j ava2 s.co  m*/
        tv.setOnClickListener(mOnPhoneClickListener);
    } else {
        UiUtils.removeTextViewDrawable(tv);
        tv.setOnClickListener(null);
    }
}

From source file:com.kyleszombathy.sms_scheduler.Home.java

private void displayErrorMessageIfDeviceCannotSendMessages() {
    PackageManager pm = this.getPackageManager();
    if (!pm.hasSystemFeature(PackageManager.FEATURE_TELEPHONY)
            && !pm.hasSystemFeature(PackageManager.FEATURE_TELEPHONY_CDMA)) {
        Toast.makeText(this, R.string.Home_Notifications_CantSendMessages, Toast.LENGTH_SHORT).show();
    }//  ww w. j  a  v a2 s  .c o m
}