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");
Related
I am working on Acer Chromebook R11. The Android version of Chromebook is 7.1.1. The external monitor is connected via HDMI port on Chromebook. OS is showing both the displays and am able to drag the apps from one window to another window.
I want my app to display on both the screens. While querying for the displays, android display manager is returning only the default display information. The external monitor information is not present with the displaymanager.
import android.hardware.display.DisplayManager;
..
..
DisplayManager displayManager = (DisplayManager) getApplicationContext().getSystemService(Context.DISPLAY_SERVICE);
Display[] var1 = displayManager.getDisplays();
Display[] var2 = displayManager.getDisplays( DisplayManager.DISPLAY_CATEGORY_PRESENTATION);
var1 is always having the default built-in screen information. I am expecting it to have information about the two displays.
var2 is always null.
Is there any issue with this API on Chromebook?
This api is working after I updated the OS on chromebook via beta channel.
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"/>
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.
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();
I am looking for any input on a problem we are having with the Galaxy S3 i9300 and our app.
We are using the Stock ICS and tested JB 4.11 from Samsung updater as well as the base code used on the Nexus 4. No matter which version we have the same issue.
Our app allows us to associate a key card with a Photo taken by a connected DSLR via an OTG cable and tags the image as well as transfer them over wireless. A Photographer uses the Android device to scan the key card, he then takes a picture of the person and the S3 transfers the image to an image processing server we created.
We have tested this on several Android devices including Verizon Samsung Galaxy Nexus with ICS, exus 7 as well as the ACER A110 and have no issues.
The issue on the S3 is that it works fine on the bulk transfer endpoint (transferring an image), but on the interrupt endpoint where we monitor for new data it doesn't like. On a Nexus we hit the interrupt 10 times a second no problem, this quickly kills the S3 though. Extending the timeout helps but does not fix. This only occurs on the S3 device and this is the most frustrating part as we did not see this issue in our initial testing and we are on site with 8 devices now and every time it drops the connection you must restart the S3.
When the USB shuts down and requires the device to be restarted before it will work again, this is logged over and over in five second intervals, even with the camera disconnected
D/UsbHostManager( 2190): onUEvent(device) :: action = remove, devtype = usb_interface, device = /proc/bus/usb/002/001, product =
1d6b/1/300, type = 9/0/0, interface = 9/0/0, devpath = /devices/platform/s5p-ohci/usb2/2-0:1.0
E/UsbHostManager( 2190): usbDeviceRemoved :: deviceName = /dev/bus/usb/002/001
D/UsbHostManager( 2190): onUEvent(device) :: action = remove, devtype = usb_interface, device = /proc/bus/usb/001/001, product =
1d6b/2/300, type = 9/0/0, interface = 9/0/0, devpath = /devices/platform/s5p-ehci/usb1/1-0:1.0
E/UsbHostManager( 2190): usbDeviceRemoved :: deviceName = /dev/bus/usb/001/001
D/UsbHostManager( 2190): onUEvent(device) :: action = add, devtype = usb_interface, device = /proc/bus/usb/001/001, product = 1d
6b/2/300, type = 9/0/0, interface = 9/0/0, devpath = /devices/platform/s5p-ehci/usb1/1-0:1.0
D/UsbHostManager( 2190): usbDeviceAdded : device :: /dev/bus/usb/001/001 [1d6bh:0002h] [09h,00h,00h] (Hub(Full speed Hub ))
W/UsbHostManager( 2190): /dev/bus/usb/001/001 is put on a blocklist [1d6bh:0002h:09h:00h:00h]
D/UsbHostManager( 2190): usbDeviceAdded : device :: /dev/bus/usb/002/001 [1d6bh:0001h] [09h,00h,00h] (Hub(Full speed Hub ))
W/UsbHostManager( 2190): /dev/bus/usb/002/001 is put on a blocklist [1d6bh:0001h:09h:00h:00h]
D/UsbHostManager( 2190): onUEvent(device) :: action = add, devtype = usb_interface, device = /proc/bus/usb/002/001, product = 1d
6b/1/300, type = 9/0/0, interface = 9/0/0, devpath = /devices/platform/s5p-ohci/usb2/2-0:1.0
We also have WIFI issues ONLY with the S3 where it cannot connect to the Cisco wireless installed throughout the location. Other Android devices connect without issue. The S3 is able to work with autonomous WAPs which is how we are testing now.
We also have a Mobile swiper attached to the S3 which works without issue. (ID-TECH Shuttle).
My developer is on site and Internet access is extremely limited. That is why I am posting this question. Please accept my apology in advance but we are looking for any ideas though the developer is convinced that it is an issue with the USB Hardware since everything else works with the same code and only the S3's have these two issues. He is quite experienced and spent more time then he had available on site with this issue. We will have to find another device if we cannot determine these two issues. FYI the Cisco is running an older WISM but other Android devices connect without issue.
Also the GT-i9300 S3 is an international version.
We tested 8 individual GT-i9300 S3 devices and they all have the same issue.