1

I have to provide some restriction on apk file while installing to the device and think off doing below restrictions:

  1. .apk file should only install on a particular device, so when user tries to install it to some other device it should flash error saying "Not a correct device to install", so the use case is when user copy the apk file in his device and double click on it, it will check whether device is correct one to install or not, if no then it should not install and flash the above mentioned error.

  2. provide password protection: when user double clicks on the apk file, it has to popup password field and user has to provide the correct password and it has to verify the password against the password which will be mentioned on manifest file.

Please provide me the solution with some examples.

Thanks,

Piks

piks
  • 1,621
  • 8
  • 32
  • 59
  • How do you want to restrict this? You can use Android version restrictions – Moises Jimenez Oct 15 '12 at 06:53
  • 1
    no, I dont want to restrict based on the version, I just want to run my app only on one type of device lets say HTC so it must not run on any other type of devices..like Samsung, Acer etc... – piks Oct 15 '12 at 06:58

4 Answers4

1

Password protecting apk files seems impossible. You can refer:

To give password to the apk

Instead you can ask the user to enter a password after installation.

This is how you can get the device name:

Get Android Device Name

Community
  • 1
  • 1
kittu88
  • 2,451
  • 5
  • 40
  • 80
0

As with password protecting an App I would say restricting devices without installing the .apk would be rather impossible. Nevertheless, you can check device manufacturer and model and from inside the App using Build.MANUFACTURER and Build.MODEL; And then you can display a Toast and force close the app if the device and/or manufacturer are not the ones you want.

Moises Jimenez
  • 1,962
  • 3
  • 21
  • 43
0

Both features can be embedded in App logic itself. A little check from Application class's onCreate() will do. Like checking device IMEI etc and setting a boolean flag, which any activity can check for.

You App won't have any control over its own install.

You can turn on copy-protection when publishing on Google play store,and also put restriction on devices (make and model) from your play store developer console.

Feature wise device restriction (like only devices with camera etc) can be provided in the App's manifest file itself.

S.D.
  • 29,290
  • 3
  • 79
  • 130
0

As with protecting your APK from unknown sources you can add licensing to your app else you can write simple function in application class and called from onCreate() method. in the function you need to check the device name with model, if it is allowed return true else return false. Based on result you can allowed or exit the app.