question

Travisty avatar image
Travisty asked

Kindle Fire HDX only is throwing exception calling Bluetooh device picker?

I am developing a Bluetooth enabled app using the standard Android API calls. Eveything works great on my Kindle Fire HD, but on the HDX it's crashing/throwing exception only when trying to show the Device Picker UI. The strange thing is all the other Bluetooth Android UI's seem to appear fine; it's just the device selector call. Any ideas? The exception: E/AndroidRuntime( 2592): FATAL EXCEPTION: main E/AndroidRuntime( 2592): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.settings/com.android.settings.wireless.bluetooth.DevicePickerActivity}: android.view.InflateException: Binary XML file line #22: Error inflating class fragment E/AndroidRuntime( 2592): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2232) E/AndroidRuntime( 2592): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2286) E/AndroidRuntime( 2592): at android.app.ActivityThread.access$600(ActivityThread.java:149) E/AndroidRuntime( 2592): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1248) E/AndroidRuntime( 2592): at android.os.Handler.dispatchMessage(Handler.java:99) E/AndroidRuntime( 2592): at android.os.Looper.loop(Looper.java:151) E/AndroidRuntime( 2592): at android.app.ActivityThread.main(ActivityThread.java:5185) E/AndroidRuntime( 2592): at java.lang.reflect.Method.invokeNative(Native Method) E/AndroidRuntime( 2592): at java.lang.reflect.Method.invoke(Method.java:511) E/AndroidRuntime( 2592): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) E/AndroidRuntime( 2592): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) E/AndroidRuntime( 2592): at dalvik.system.NativeStart.main(Native Method) E/AndroidRuntime( 2592): Caused by: android.view.InflateException: Binary XML file line #22: Error inflating class fragment E/AndroidRuntime( 2592): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) E/AndroidRuntime( 2592): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746) E/AndroidRuntime( 2592): at android.view.LayoutInflater.inflate(LayoutInflater.java:489) E/AndroidRuntime( 2592): at android.view.LayoutInflater.inflate(LayoutInflater.java:396) E/AndroidRuntime( 2592): at android.view.LayoutInflater.inflate(LayoutInflater.java:352) E/AndroidRuntime( 2592): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:271) E/AndroidRuntime( 2592): at android.app.Activity.setContentView(Activity.java:1911) E/AndroidRuntime( 2592): at com.android.settings.SettingsBaseActivity.setContentView(SettingsBaseActivity.java:127) E/AndroidRuntime( 2592): at com.android.settings.wireless.bluetooth.DevicePickerActivity.onCreate(DevicePickerActivity.java:34) E/AndroidRuntime( 2592): at android.app.Activity.performCreate(Activity.java:5158) E/AndroidRuntime( 2592): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080) E/AndroidRuntime( 2592): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2186) E/AndroidRuntime( 2592): ... 11 more E/AndroidRuntime( 2592): Caused by: android.app.Fragment$InstantiationException: Unable to instantiate fragment com.android.settings.bluetooth.DevicePickerFragment: make sure class name exists, is public, and has an empty constructor that is public E/AndroidRuntime( 2592): at android.app.Fragment.instantiate(Fragment.java:592) E/AndroidRuntime( 2592): at android.app.Fragment.instantiate(Fragment.java:560) E/AndroidRuntime( 2592): at android.app.Activity.onCreateView(Activity.java:4751) E/AndroidRuntime( 2592): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680) E/AndroidRuntime( 2592): ... 22 more E/AndroidRuntime( 2592): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.android.settings.bluetooth.DevicePickerFragment" on path: /system/framework/android.amazon.res.jar:/system/framework/eaclibrary.jar:/system/framework/com.amazon.kindle.cms.jar:/system/app/FireSettings.apk:/system/app/AmazonWebViewLib.apk:/system/app/DeviceMessagingAndroidInternalSDK.apk:/system/app/MetricsApi-2037410.apk:/system/app/com.amazon.dcp.contracts.apk:/system/app/com.amazon.dcp.contracts.framework.apk:/system/app/com.amazon.device.settings.sdk.internal.apk E/AndroidRuntime( 2592): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65) E/AndroidRuntime( 2592): at java.lang.ClassLoader.loadClass(ClassLoader.java:501) E/AndroidRuntime( 2592): at java.lang.ClassLoader.loadClass(ClassLoader.java:461) E/AndroidRuntime( 2592): at android.app.Fragment.instantiate(Fragment.java:582) E/AndroidRuntime( 2592): ... 25 more
fire tablet
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Sujoy@Amazon avatar image
Sujoy@Amazon answered
Hi Travisty, Can you please provide the code that is not working in HDX?
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Travisty avatar image
Travisty answered
Sure: // Launch the DeviceListActivity to see devices and do scan mContext.startActivity(new Intent(BluetoothDevicePicker.ACTION_LAUNCH) .putExtra(BluetoothDevicePicker.EXTRA_NEED_AUTH, false) .putExtra(BluetoothDevicePicker.EXTRA_FILTER_TYPE, BluetoothDevicePicker.FILTER_TYPE_ALL) .setFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS)); ... class BluetoothDevicePicker { ... public static final String ACTION_LAUNCH = "android.bluetooth.devicepicker.action.LAUNCH"; public static final String EXTRA_NEED_AUTH = "android.bluetooth.devicepicker.extra.NEED_AUTH"; public static final String EXTRA_FILTER_TYPE = "android.bluetooth.devicepicker.extra.FILTER_TYPE"; /** Ask device picker to show all kinds of BT devices */ public static final int FILTER_TYPE_ALL = 0; }
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Sujoy@Amazon avatar image
Sujoy@Amazon answered
Hi Travisty, Thanks for the code. I have forwarded the issue to the concerned team.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Travisty avatar image
Travisty answered
Any udpates? I have seen other apps that show the standard Android Bluetooth device picker on the HDX, it's just crashing when I try it the standard method to do it. Is the HDX missing the core libraries that the Fire HD has?
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Sujoy@Amazon avatar image
Sujoy@Amazon answered
Hi Travisty, Can you please share the app name where you see the functionality working? I have already informed the team about the fact that the standard way of displaying Bluetooth device picker does not work in Kindle HDX. Officially I can not comment on the ETA for fixing this issue. Thanks.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Travisty avatar image
Travisty answered
NBA2K14 by 2K Games has a bluetooth online play feature, and pops open the standard Android device picker dialog on both the HDX and Fire HD. Let me know if theres anything else I can do to help you out.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Sujoy@Amazon avatar image
Sujoy@Amazon answered
Hi Travisty, Thanks for the information. Could you tell me where should find the Bluetooth device picker in the app you mentioned. I downloaded the app and played through it but did not find any link to launch the picker from the app. Please note, as we have discovered before that BluetoothDevicePicker.ACTION_LAUNCH does not work in HDX and that issue is reported to the concerned team, officially I can not comment on the ETA of the fix. But if there is any alternative that can serve your purpose we can sure figure that out.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Travisty avatar image
Travisty answered
From the games main menu, click "Multiplayer", then "Bluetooth". Then click "Allow" in the standard Android "An app wants to turn on Bluetooth" dialog. Next click "Allow" for the standard Android dialog to allow your device to be discoverable for 30 sec. At this point you should see the standard picker screen that allows you to "select a device to connect" with a list of all nearby BT compatible devices with a scan button I have screenshots I can send to if you give me a place to upload/email them to.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Sujoy@Amazon avatar image
Sujoy@Amazon answered
Travisty, Yes. Got it. They are doing it in native way by using android.bluetooth package and displaying the devcies in a custom view. Below is the sample code to do it. package com.javacodegeeks.android.bluetoothtest; import android.os.Bundle; import android.app.Activity; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; import android.content.BroadcastReceiver; import android.content.Context; import java.util.Set; import android.content.Intent; import android.content.IntentFilter; import android.view.View; import android.view.View.OnClickListener; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.ListView; import android.widget.TextView; import android.widget.Toast; public class MainActivity extends Activity { private static final int REQUEST_ENABLE_BT = 1; private Button onBtn; private Button offBtn; private Button listBtn; private Button findBtn; private TextView text; private BluetoothAdapter myBluetoothAdapter; private Set pairedDevices; private ListView myListView; private ArrayAdapter BTArrayAdapter; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // take an instance of BluetoothAdapter - Bluetooth radio myBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); if(myBluetoothAdapter == null) { onBtn.setEnabled(false); offBtn.setEnabled(false); listBtn.setEnabled(false); findBtn.setEnabled(false); text.setText("Status: not supported"); Toast.makeText(getApplicationContext(),"Your device does not support Bluetooth", Toast.LENGTH_LONG).show(); } else { text = (TextView) findViewById(R.id.text); onBtn = (Button)findViewById(R.id.turnOn); onBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub on(v); } }); offBtn = (Button)findViewById(R.id.turnOff); offBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub off(v); } }); listBtn = (Button)findViewById(R.id.paired); listBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub list(v); } }); findBtn = (Button)findViewById(R.id.search); findBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub find(v); } }); myListView = (ListView)findViewById(R.id.listView1); // create the arrayAdapter that contains the BTDevices, and set it to the ListView BTArrayAdapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1); myListView.setAdapter(BTArrayAdapter); } } public void on(View view){ if (!myBluetoothAdapter.isEnabled()) { Intent turnOnIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); startActivityForResult(turnOnIntent, REQUEST_ENABLE_BT); Toast.makeText(getApplicationContext(),"Bluetooth turned on" , Toast.LENGTH_LONG).show(); } else{ Toast.makeText(getApplicationContext(),"Bluetooth is already on", Toast.LENGTH_LONG).show(); } } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { // TODO Auto-generated method stub if(requestCode == REQUEST_ENABLE_BT){ if(myBluetoothAdapter.isEnabled()) { text.setText("Status: Enabled"); } else { text.setText("Status: Disabled"); } } } public void list(View view){ // get paired devices pairedDevices = myBluetoothAdapter.getBondedDevices(); // put it's one to the adapter for(BluetoothDevice device : pairedDevices) BTArrayAdapter.add(device.getName()+ "\n" + device.getAddress()); Toast.makeText(getApplicationContext(),"Show Paired Devices", Toast.LENGTH_SHORT).show(); } final BroadcastReceiver bReceiver = new BroadcastReceiver() { public void onReceive(Context context, Intent intent) { String action = intent.getAction(); // When discovery finds a device if (BluetoothDevice.ACTION_FOUND.equals(action)) { // Get the BluetoothDevice object from the Intent BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); // add the name and the MAC address of the object to the arrayAdapter BTArrayAdapter.add(device.getName() + "\n" + device.getAddress()); BTArrayAdapter.notifyDataSetChanged(); } } }; public void find(View view) { if (myBluetoothAdapter.isDiscovering()) { // the button is pressed when it discovers, so cancel the discovery myBluetoothAdapter.cancelDiscovery(); } else { BTArrayAdapter.clear(); myBluetoothAdapter.startDiscovery(); registerReceiver(bReceiver, new IntentFilter(BluetoothDevice.ACTION_FOUND)); } } public void off(View view){ myBluetoothAdapter.disable(); text.setText("Status: Disconnected"); Toast.makeText(getApplicationContext(),"Bluetooth turned off", Toast.LENGTH_LONG).show(); } @Override protected void onDestroy() { // TODO Auto-generated method stub super.onDestroy(); unregisterReceiver(bReceiver); } }
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.