简体   繁体   中英

Can an Android app only allow itself to be installed on devices with a magnetic sensor?

Can an Android app only allow itself to be installed from Google Play on devices with a magnetic sensor (compass)?

Is it possible to restrict target devices in other ways?

Add this to your AndroidManifest.xml

<uses-feature
  android:name="android.hardware.sensor.compass"
  android:required="true" />

See more details here .

As @Zoe mentioned, it will hide on Play Store but not Block installation if someone has the APK. If you want to block the use of app then you can add a check in your starting activity and prevent user from using any feature.

PackageManager mgr = getPackageManager();
boolean hasCompass = mgr.hasSystemFeature(PackageManager.FEATURE_SENSOR_COMPASS);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM