-2

Can I make my android app not work on certain Android phones ? For example, if I don't want my app to work on Samsung J5 2016 Phones, can I do that?

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
  • Welcome to SO! I'm going to edit your question a bit to remove extraneous information and improve grammar - this is so it is more useful for others in future. –  May 05 '18 at 17:17
  • https://support.google.com/googleplay/android-developer/answer/7353455?hl=en – Luca Kiebel May 05 '18 at 17:17
  • 1
    your question is basically `how to get phone model`, right? – Vladyslav Matviienko May 05 '18 at 17:18
  • 1
    Possible duplicate of [Get Android Phone Model Programmatically](https://stackoverflow.com/questions/1995439/get-android-phone-model-programmatically) – feedc0de May 05 '18 at 19:25

3 Answers3

2

You can do it easily by using the Build variable in your condition.

android.os.Build.MODEL

android.os.Build.BOARD;

android.os.Build.BRAND;

android.os.Build.PRODUCT

if(android.os.Build.MODEL.equalIgnoreCase("Device Model")){ finish();}
Alok
  • 881
  • 1
  • 11
  • 18
0

Just check for the model and show some dialog for non-supporting devices.

String myDeviceModel = android.os.Build.MODEL;

if(myDeviceModel.equals("someBoringDevice")){
   //show alert dialog
   //finish()
   return;
}

if you have more then one abandoned devices. simple call this in for loop.

String myDeviceModel = android.os.Build.MODEL;
for(String deviceModel:modelArray){  
    if(myDeviceModel.equals(deviceModel)){
       //show alert dialog
       //finish()
       return;
    }
}
vikas kumar
  • 10,447
  • 2
  • 46
  • 52
  • Thank you bro for your help, can you please tell where can i insert different Device Models here in for loop – Issam El Mourabit May 05 '18 at 17:39
  • @IssamElMourabit He already told you. In the above example code, they would be stored in `modelArray`. If you don't know how arrays work, you might want to go through some beginner Java courses before diving futher into Android development. – Matt May 05 '18 at 18:13
0

I think you can just check for the android.os.Build.VERSION_CODES. For example, if you want to block android 7, check for the version code:

public static final int LOLLIPOP = 21;

public static final int LOLLIPOP_MR1 = 22;

Because API Level 21 and 22 are android 7 version. 23 is Nougat.