Other similar questions in SO are answered by retrieving the Build.MODEL name.
But what I would really like is to get the customizable Device name on Samsung Devices. I know it is customizable because on my Galaxy Note, I can change it from the settings->About device. For example, below, I would like to retrieve the "Milky Way" string.
There is no common way getting this, since it's not a "android-feature" more likely a Samsung Feature afaik.
Try getting it with this, which worked on my galaxy s3, s4 and s5
BluetoothAdapter myDevice = BluetoothAdapter.getDefaultAdapter();
String deviceName = myDevice.getName();
Do not forget to add the bluetooth permissions.
<uses-permission android:name="android.permission.BLUETOOTH"/>
I tried
BluetoothAdapter myDevice = BluetoothAdapter.getDefaultAdapter();
String deviceName = myDevice.getName();
still returns the SM-G900H.
After some research I found the device_name in /data/data/com.android.providers.settings/databases/settings.db
I manage to get it using following shell command
settings get system device_name
Code:
String deviceName = Settings.System.getString(getContentResolver(), "device_name");
Settings.Global.getString(context.getContentResolver(), "device_name")
It working for me.
Related
I have been searching for code through which I can fetch Device's name defined by user for his own device .
Have gone through various stackoverflow questions , but none seems to work for me ?
Image as seen in below : Will require Thanks Thanks (SM-T211 ) from android code
Try this:
String ownerInfo = Settings.Secure.getString(getContentResolver(),
"lock_screen_owner_info");
As of Android 4.4.2 the owner info value is moved to lock screen database,/data/system/locksettings.db to which 3rd-party apps have no read/write access. That's, there is no reliable way of reading owner info for later Android versions except for rooted device.
You need to get build.prop file of system which is possible either if your device is rooted or if your has system privileges....
heres the code you may follow to get and edit build.prop
Check this App in Play Store. build.prop Editor. Since it's open source, and the code is extremely simple, you can use it as a stating point: https://github.com/nathanpc/Build.prop-Editor
Try this :
BluetoothAdapter myDevice = BluetoothAdapter.getDefaultAdapter();
String deviceName = myDevice.getName();
Make sure you add to your manifest:
<uses-permission android:name="android.permission.BLUETOOTH"/>
In Android you can set a username for the device. I've set up a few devices where it asked me for my first name and last name. I was wondering how to retrieve this. In iOS you can get a name like "Kate's iPhone" for the device name which is what I want to do on Android. Additionally in a game I'd like to fill in the Characters name with the persons name. So I could essentially say String.format("Hello, %s", getUsername); Is this possible in Android down to API 10? The only thing I've found is UserManager with a getUserName() method, but it is only available at API level 17 which I think lines up with when Android allowed tablets to have multi user support... so I'm not sure it will actually give a valid response on a phone. Does anyone have any ideas?
I am not looking for device name (e.g. Nexus 7, Nexus 4, Samsung Galaxy S5).
This works on a real phone, in an Emulator you will get an empty String.
BluetoothAdapter myDevice = BluetoothAdapter.getDefaultAdapter();
String deviceName = myDevice.getName();
Toast.makeText(this, "Phone "+deviceName, Toast.LENGTH_LONG).show();
Remember to add the permission to the Manifest:
<uses-permission android:name="android.permission.BLUETOOTH"/>
I have an apk which get the device name defined by the user.
For that I use this code (see at How do you get the user defined “Device Name” in android?):
BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
TextView txtName = (TextView) findViewById(R.id.name);
txtName.setText(mBluetoothAdapter.getName());
It works well on a android 4.1 / Samsung Galaxy tab3. Unfortunately when I test it on android 4.4 Samsung Galaxy tab pro, it doesn't work. On the new device I get the same result like android.os.Build.MODEL
If someone have an idea.
Thanks
Try to get it from Settings.Secure:
Settings.Secure.getString(getContentResolver(), "bluetooth_name");
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();
When I try to get device_id of my Samsung Galaxy Tab GT-P1010, It returns null value. I 'm using device_id for identify unique device in my database.
I am using following code for this:
String device_id;
TelephonyManager telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
device_id = telephonyManager.getDeviceId();
Here I'm getting string device_id null.. This code is working fine for my all other device, HTC, LG, Google NExxus ICS etc..
Please give me solution for it ASAP.
Thanks,
Jay Patel
If your requirement is only to generate unique identification of device, you can use the below code:
UUID id=UUID.randomUUID();
//store this in shared pref
String device_id=id.toString();
//later fetch it from share pref
UUID Id=UUID.fromString(device_id);
This is the standard way of recognising the device according to RFC4122
getDeviceId() returns the device's IMEI or MEID, which is tied to the device's SIM card. It sounds like your Galaxy Tab is a wi-fi only device, and has no SIM card; that's why it's not giving you a valid device id.
Unfortunately there is no way to get a device id from a wi-fi only device; I'd suggest using ANDROID_ID or some other id if you get a null value for getDeviceId().