Identify if device is Kindle - android

I have an Android app I'd like to offer on the Amazon's AppStore. My app has some location-based features and camera features which I need to disable if the user's device is a Kindle. Is there a way to programmatically detect if a user's Device is a Kindle? I'm aware I can build different versions for Kindle and non-Kindle but I thought I'd first ask if there's a way to detect this in code.

To check if the device has a certain feature, you PackageManager.hasSystemFeature(String name) which should be sufficient in your case.
To check for location and camera you can use FEATURE_LOCATION and FEATURE_CAMERA as argument to hasSystemFeature
If you still need to know the hardware of your device, you can check
android.os.Build.MANUFACTURER
android.os.Build.BRAND
android.os.Build.BOARD
android.os.Build.DEVICE

If you want to detect Kindle, check for manufacturer (Amazon) using Build.MANUFACTURER and model using Build.MODEL. The value of model in case of Kindle will vary, it can be KFTT, KFOT, Kindle Fire, etc. See this for model nos.

You can use this method in identifying a Kindle Device(s)
public static boolean isKindle(){
final String AMAZON = "Amazon";
final String KINDLE_FIRE = "Kindle Fire";
return (Build.MANUFACTURER.equals(AMAZON) && Build.MODEL.equals(KINDLE_FIRE) ) || Build.MODEL.startsWith("KF");
}

I know that this post is old, but the approach to this is wrong. If your concern with Kindles is hardware related i.e. Kindles do not have a camera or camera support then you need to check for camera support not device type. What if other devices do not offer camera support? Instead of suggested answer, try this
public static boolean isCameraAvailable(Context context) {
PackageManager packageManager=context.getPackageManager();
if (packageManager.hasSystemFeature(PackageManager.FEATURE_CAMERA_ANY)) {
// this device has a camera
return true;
} else {
// no camera on this device
return false;
}
}
This is much better than detecting for if device is a kindle, otherwise do another build specific for kindle.

Related

Android : How to detect the device is Huawei or not?

I am trying to find a way to detect whether the device is Huawei or not.
My app has a piece of code that causes a crash on Huawei devices, I want to avoid executing that code if the device is Huawei.
I don't want to use checks based on GMS & HMS availability cause my app does not contain dependency for these packages.
Thanks
Try this. The Code standard is poor, but it gets the job done. I don't think Huawei will ever change its name.
private boolean isHuaweiDevice(){
String manufacturer = android.os.Build.MANUFACTURER;
String brand = android.os.Build.BRAND;
return manufacturer.toLowerCase().contains("huawei") || brand.toLowerCase().contains("huawei");
}

Allow user to access wifi settings without giving free reign

We are developing a locked down "kiosk-style" Android app on a stock Samsung tablet, which is mounted in customer vehicles. We would like to be able to allow customers to edit their wifi settings, without giving them access to the rest of the Settings app (e.g. Launcher, accounts, etc)
We have been able to launch the Wifi Settings activity, but it allows the user to go into other areas.
I'm not sure whether it's possible to create a custom interface for connecting to wifi, but even if it were possible, this seems fragile and a lot of work for something quite simple.
Is there any way to solve this well?
I would create a device policy controller app that is provisioned on the device as a device owner using Android Enterprise (Android for Work) APIs.
https://developers.google.com/android/work/dpc/build-dpc
As a device owner, you can set your app in lock task mode which is generally used for kiosks.
https://developer.android.com/work/cosu.html
Then, you can set user restrictions:
addUserRestriction api
user restrictions list
The user restrictions don't cover everything in the settings app, but the coverage is pretty good.
Then I would provision it using NFC or QR code reader from the Google Setup Wizard welcome screen.
https://github.com/googlesamples/android-NfcProvisioning
You might want to also look at existing open source EMM/MDM implementations that already exist such as WSO2.
Other references:
How to enable task locking in Android 5.0 production devices
How to make sure there is only one app
I was also working on Kiosk Type applications and we have to give options for Change wifi and Display Settings So we have used these commands on Button click for Wifi And Display
Settings
btnWifiSetting.setOnClickListener {
startActivityForResult( Intent(android.provider.Settings.ACTION_WIFI_SETTINGS), 0);
}
And For Display Setting
btnDisplay.setOnClickListener {
startActivityForResult(Intent(android.provider.Settings.ACTION_DISPLAY_SETTINGS),0)
}
And you can also check the full list of Available Commands here
https://ourcodeworld.com/articles/read/318/how-to-open-android-settings-programmatically-with-java
try LineAgeOS
https://lineageos.org/
Your requirement needs to access OS System level, this way you have access and customize the WIFI settings before releasing the phone itself
can you try this way.
WifiManager wifiManager = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE);
if (wifiManager.isWifiEnabled()) {
wifiManager.setWifiEnabled(false);
Tools_WiFi.setImageResource(R.drawable.tool_wifi_off);
} else {
wifiManager.setWifiEnabled(true);
Tools_WiFi.setImageResource(R.drawable.tool_wifi_on);
}
You can try this:
startActivityForResult(new Intent(Settings.ACTION_WIFI_SETTINGS), 0);
Hope it helps you.

Maintain single device for registering account of my app

I am designing a chat application with registered phone number for both iOS and android app.
I want to make sure that this number and app works on one phone at a time, as below scenarios given I want to make sure that app once authenticated to another device with same account details disable the previous device.
1) app installed on one iOS device registered account and deleted and reinstalled on same device again
2) app installed on iOS phone then same account is validated on android app the iOS phone app should show disabled account
3) app installed on two android phone with same number should disable old one automatically.
Reason is I don't want multiple copies of application with same number running to avoid like whatsapp does.
I am thinking of device keychain for iOS and android Mac Id usage to get this worked out since apple stopped UDID broadcasting to server.
Also have a vague Idea about this vendor id apple providing.
Can anyone advice on this. How can I achieve so app is running with same account on one phone only and other just stops.
If you are binding an app with a phone number getting registered then it can run only on one device since you can't have same ph number running on 1+ devices at the same time. From user's perspective if he is changing same number between multiple handsets, going by your case, this app is blocking previous device of user, it sounds like a never ending loop. Everytime user's previous device is getting blocked or it may result in blocking all user's device. Dosen't make sense to me at least.
Below method is for getting device ID
public static String getDeviceID(Context p_context) throws Throwable
{
String m_deviceID = null;
TelephonyManager m_telephonyManager = null;
m_telephonyManager = (TelephonyManager) p_context
.getSystemService(Context.TELEPHONY_SERVICE);
m_deviceID = m_telephonyManager.getDeviceId().toString();
if (m_deviceID == null || "00000000000000".equalsIgnoreCase(m_deviceID))
{
m_deviceID = "AAAAAAA";
}
return m_deviceID;
}
More information about the identification you can read here.

How to know whether my App is running on Bluestacks?

I'm working on a special version of my App which should run in Bluestacks. It's a windows/mac application which allows to run Android apps on the computer.
I would like to implement special behaviour when the app runs in Bluestacks. Nothing complicated, maybe showing a dialog or disabling some buttons.
But for that purpose I need to know whether the app is running on a Bluestacks device. I checked the device model (Build.MODEL) and manufacturer (Build.MANUFACTURER), but I get that the device is a Samsung GT i900.
Does someone know an unambiguous way to know whether an app is running on Bluestacks?
I know it´s rather a quite localized question, but it would be fine if I get some ideas about where to look at, or what to try.
Try this:
/**
* Returns true if device is Android port to x86
*/
public static boolean isx86Port()
{
String kernelVersion = System.getProperty("os.version");
if(kernelVersion != null && kernelVersion.contains("x86")) // for BlueStacks returns "2.6.38-android-x86+"
return true;
return false;
}
try below code:
File test = new File("/data/Bluestacks.prop");
boolean isRunningInBluestacks = test.exists();
Finally I decided to build a new app for Bluestacks using an Android library. This allows me to add special behaviour for the bluestacks app.
I tried to get all the info using the Build class, but it returns the same as a Samsung Galaxy GT i9000 device, so it's impossible to know that the device is running in bluestacks.
This Will be unique.
There is no bluetooth device in Bluestack.
So try to get The Bluetooth Address string which is always 'null' on Bluestack or Any emulator.Make sure you are adding Bluetooth permission on your project manifest.
BluetoothAdapter m_BluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
String m_bluetoothAdd = m_BluetoothAdapter.getAddress();

How to find out whether a particular device has SIM Hardware support?

I wanted to disable features related to CALL and SMS in my application based on whether SIM hardware is present or not. Now a beginners approach towards this will be checking the Phone type using :
if (telephonyManager1.getPhoneType() == TelephonyManager.PHONE_TYPE_NONE)
If true then its supported.
Everything was fine until i came across Sony Tablet S which has a SIM support only for Data and Messaging. No voice support. So for this device i need to disable only CALL feature but continue with SMS support.
Sony tablet returns TelephonyManager.PHONE_TYPE_NONE so i can`t use the above methods.
Also ,
telephonyManager1.getSimState();
returns 1 i.e SIM_STATE_ABSENT which is also same in case of HTC FLYER which has no support for SIM hardware itself.
So is there any way in which i can come to know if SIM hardware is there(irrespective of SIM card inserted or not) ?
Use
PackageManager pm = this.getPackageManager();
boolean hasTelephony=pm.hasSystemFeature(PackageManager.FEATURE_TELEPHONY);
Edit:
Try using
TelephonyManager.getLine1Number()
If this returns null then you wont have telephony feature. Have not tried. give it a shot

Categories

Resources