I want to find device specification of a mobile phone for examples, the device manufacturer, model no ( and may be types of sensors in the device, wifi chipset etc..). I want to get the device manufacture/model number (eg. Samsung GT-I9100 i.e Galaxy S2) programmatically. The manufacture/model number is also used in Google Play when installing an app. I want to use this information to make some configuration changes in my hardware dependent app (for eg. power measurement).
You can get as below:
String deviceName = android.os.Build.MODEL;
String deviceMan = android.os.Build.MANUFACTURER;
For more other device details, Please refer this document: android.os.Build
I just wanna elaborate on how to use the built in Attribute for the future visitors. 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");
}
String deviceName = android.os.Build.MODEL;
String deviceMan = android.os.Build.MANUFACTURER;
The original solution will work fine, however it will not detect a custom ROM (non OEM) in call cases. You may want to also evaluate the android.os.Build.PRODUCT string or other strings from the Build class.
String build = android.os.Build.PRODUCT;
Related
I trying to create an app that can detect a usb devices. The android device act like a Host, and I now only need to read data of attached devices.
I import android.hardware.usb.UsbDevice
All work fine, but the problem is with any usbDevice methods. I can read the usbDevice.getDeviceName() method but I can't use for example getVersion(), whY?
He say me that cannos resolve this method. Also about other methods.
private String readDevice(UsbDevice device) {
StringBuilder sb = new StringBuilder();
String a = device.getDeviceName(); //work
String b = device.getVersion(); //doesn't work
}
You need to read This Link
It's included in API 23.
String versionStr = UsbDevice.getVersion();
Or you may help from This Link
I am working on Amazon FireTV. Is there any API so that i can differentiate whether its a FireTV or FireStick. like
String modal = android.os.Build.Modal;
if(modal.equals(FireTV)){ }else if(modal.equals(FireStick)){ }
Any help will be appreciated.
You can check the Model name:
public String MODELNAME = android.os.Build.MODEL;
public boolean ISFIRETV = MODELNAME.equalsIgnoreCase("AFT*");
public boolean ISFIRETVSTICK = MODELNAME.equalsIgnoreCase("AFTM");
All Fire TV devices have a model name which starts with "AFT":
FireTV (2nd Gen) is "AFTS"
FireTV (1st Gen) is "AFTB"
FireTV Stick is "AFTM".
ISFIRETV can then be used to ensure that it is a FireTV device of any kind (and not for instance sideloaded onto a non-Fire TV device), and then ISFIRETVSTICK can be used to specifically check if it is a FireStick or not.
Besides of answer below there is one more way to check it:
final String AMAZON_FEATURE_FIRE_TV = "amazon.hardware.fire_tv";
if (getPackageManager().hasSystemFeature(AMAZON_FEATURE_FIRE_TV)) {
Log.v(TAG, "Yes, this is a Fire TV device.");
} else {
Log.v(TAG, "No, this is not a Fire TV device.");
}
According to documentation this is the recommended way. But to use it you should have a Context.
In my Android app I want to detect all Android device names found in the local wireless network. I am able to scan the network and find the devices IP and full qualified domain name (FQDN) like android-2120ee3b45******. I'm doing it like:
final InetAddress inetAddress = InetAddress.getByName(ip);
if (inetAddress.isReachable(400)) {
final String host = inetAddress.getHostName();
final String canHost = inetAddress.getCanonicalHostName();
final String ip = inetAddress.getAddress();
}
With java.net.InetAddress I only get the IP and the network name like android-2120ee3b45******. But I want the Android device name defined by the user on the device like "Peters Fire TV" or "Mikes Samsung SGS6". I saw apps like AllConnect or AllCast which can grab such name from Fire TV (which is a android device).
How can I get the Android device name defined by the user over the WIFI network?
add this line,
for(i=0;i<WifiP2pDeviceList.size();i++){
WifiP2pDevice device = WifiP2pDeviceList.get(i);
String deviceName=device.deviceName;
String devicestatus=device.status;
//so on
}
In my android application, BLE connection is working successfully, once BLE device has been connected to Android phone. How to change the connected BLE device name programatically? Sample code like below
private static final UUID Device_Name_UUID = UUID.fromString("00002a00-0000-1000-8000-00805f9b34fb");
private static final UUID Write_UUID = UUID.fromString("00001800-0000-1000-8000-00805f9b34fb");
public void Device_Name(){
BluetoothGattService Name_Service = mBluetoothGatt.getService(Write_UUID );
if(Name_Service == null) {
Log.d(TAG, "Name_Service service not found!");
return;
}
BluetoothGattCharacteristic DeviceName = Name_Service.getCharacteristic(Device_Name_UUID);
if(DeviceName == null) {
Log.d(TAG, "DeviceName charateristic not found!");
return;
}
}
Log.v(TAG, "readCharacteristic(DeviceName) = " + mBluetoothGatt.readCharacteristic(DeviceName));
String i = "123";
DeviceName.setValue(i);
Log.v(TAG, "writeCharacteristic(DeviceName) = " + mBluetoothGatt.writeCharacteristic(DeviceName));
Log.v(TAG, "writeCharacteristic(DeviceName) = " + mBluetoothGatt.writeCharacteristic(DeviceName));
Here mBluetoothGatt.writeCharacteristic(DeviceName); method always returns false.
After some Research I found Below solution
You need to modify the firmware of CC2541 keyfob to add the write permission of device name by adding the code below into KeyFobApp_Init() inside keyfobdemo.c:
uint8 devNamePermission = GATT_PERMIT_READ|GATT_PERMIT_WRITE;
GGS_SetParameter( GGS_W_PERMIT_DEVICE_NAME_ATT, sizeof ( uint8 ), &devNamePermission );
Now my question is, where we need to add these permissions?
Please can anybody tell me that how to add these persmissions?
Thanks in advance
As the name indicates: keyfobdemo.c is a .c file, so TI is telling you that you have to add those permissions in the KeyFobDemo workspace, so you have to program the CC2541 kit in order to change the name. You cannot do it in Android.
All you have to do is:
Download the BLE stack from Texas Instruments website:
http://www.ti.com/tool/ble-stack
Then in the stack, open Projects\ble\KeyFob\CC2541DB\KeyFobDemo.eww file.
Programming of CC2540 kit requires an IDE named IAR Embedded Workbench. You can download it and get access with 30-days trial:
http://www.iar.com/Products/IAR-Embedded-Workbench/8051/
Then open the project and find the keyfobdemo.c file in the APP folder. From line 200-213 there is a char array named deviceName[], which actually defines the advertising name as "Keyfobdemo". You just have to change that to the desired name with correct hex values, and the length of the array as well.
Then in line 236, you have to change attDeviceName[] array as well, since this parameter defines the name of your device once it is in connected state.
No way to do that in Android! unless you change your BLE firmware!
Possible solution, once you connected to your BLE device, you could send some configuration command to your device to change the device name.
I have an application. It is used to send and receive files using Bluetooth. My problem is, i wish to change the default location to store the file using Bluetooth at runtime. Can you tell me, Is there any possibility for this case?
It's not possible to configure it up to Android 4.1 Jelly Bean:
With the included stock bluetooth receiver you cannot change the location as of now, because it's hard coded. You need a 3rd party app like Bluetooth file transfer which might be configurable here.
In ./packages/apps/Bluetooth/src/com/android/bluetooth/opp/ you can see it.
Constants.java defines this:
public static final String DEFAULT_STORE_SUBDIR = "/bluetooth";
BluetoothOppReceiveFileInfo.java has no switch for the location:
File receiveFile = new File(uniqueFileName);
if (sDesiredStoragePath == null) {
sDesiredStoragePath = Environment.getExternalStorageDirectory().getPath() +
Constants.DEFAULT_STORE_SUBDIR;
}