1

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

enter image description here

Yatin
  • 2,969
  • 9
  • 34
  • 68
  • which one ?? can you elaborate by example ?? – Janki Gadhiya Jul 15 '16 at 10:30
  • where does the user define device name? – eriuzo Jul 15 '16 at 10:36
  • AFAIK i dont see any user editable control in settings > about. can you provide a screenshot? – eriuzo Jul 15 '16 at 10:41
  • Please check image added – Yatin Jul 15 '16 at 10:43
  • @Yatin try the below answer that I gave. – Mande Kira Jul 15 '16 at 10:46
  • 1
    AFAIK thats device / manufacturer specific. I dont have that feature in my device (Asus Zenfone 2) – eriuzo Jul 15 '16 at 10:54
  • if the "Thanks Thanks" name shows up as bluetooth device name in your other devices, you can use the bluetooth answer, if not you have to use the build.prop answer – eriuzo Jul 15 '16 at 10:57
  • From bluetooth I do get it but ,its the other device's name which I am pairing with device.getName() property from bluetooth adapter . How to get my own device name ... is the question – Yatin Jul 15 '16 at 11:02
  • So , from below answers I assume that to get answer , I will have to root the device , else I wont be able to retrieve Device name from my own device . – Yatin Jul 15 '16 at 11:28
  • 1
    Possible duplicate of [How do you get the user defined "Device Name" in android?](https://stackoverflow.com/questions/16704597/how-do-you-get-the-user-defined-device-name-in-android) – Dan J May 10 '19 at 03:02

3 Answers3

1

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.

Mande Kira
  • 190
  • 1
  • 14
  • FYI, you can find a more detailed answer listing all the options here: https://medium.com/@pribble88/how-to-get-an-android-device-nickname-4b4700b3068c – Dan J May 07 '19 at 14:28
1

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

Flexo
  • 87,323
  • 22
  • 191
  • 272
tanmeet
  • 220
  • 2
  • 11
0

Try this :

BluetoothAdapter myDevice = BluetoothAdapter.getDefaultAdapter();
String deviceName = myDevice.getName();

Make sure you add to your manifest:

<uses-permission android:name="android.permission.BLUETOOTH"/>
earthw0rmjim
  • 19,027
  • 9
  • 49
  • 63
Lubomir Babev
  • 1,892
  • 1
  • 12
  • 14