title: Android: Trying to start BluetoothSettings activity Force Close with NullPointerException
body: <p>I'm trying to bring up the standard window for Bluetooth Settings(with Device name, Discoverability etc).</p>
  
  <p>However, general approach with <code>startActivity(intent)</code> ends with NullPointerException pointing to<code>BluetoothSettings.java onCreate:135.</code></p>
  
  <p>Checking with the Android code, I've found that at line 135 they get some extras from the intent. So I prepare the same extras (names I've found in android core BluetoothDevicePicker interface) and issue it -- the same effect with NullPointerException.</p>
  
  <p>Might be the wrongs names of the extras I prepare?</p>
  
  <p>So is there a way I can see those extras (with names especially) from the intent the system itself submits when I open Bluetooth Settings manually acting like a user?</p>
  
  <p>Many thanks.</p>
  
  <p>My code is:</p>
  
  <pre><code>Intent settingsIntent = new Intent();
  settingsIntent.setClassName("com.android.settings",      com.android.settings.bluetooth.BluetoothSettings");
  settingsIntent.putExtra("android.bluetooth.devicepicker.extra.LAUNCH_PACKAGE", "mypackage.bttoggle");
  settingsIntent.putExtra("android.bluetooth.devicepicker.extra.DEVICE_PICKER_LAUNCH_CLASS", "mypackage.bttoggle.BluetoothWidget");
  PendingIntent settingsPendingIntent = PendingIntent.getActivity(context, 0, settingsIntent, 0);
  views.setOnClickPendingIntent(R.id.btnSettings, settingsPendingIntent);
  </code></pre>
  
  <p>It's a widget so I need to use PendingIntent.</p>
  
  <p>This code get the following Exception at runtime:</p>
  
  <blockquote>
    <p>ERROR/AndroidRuntime(4905): Uncaught handler: thread main exiting due
    to uncaught exception ERROR/AndroidRuntime(4905):
    java.lang.RuntimeException: Unable to start activity
    ComponentInfo{com.android.settings/com.android.settings.bluetooth.BluetoothSettings}:
    java.lang.NullPointerException ERROR/AndroidRuntime(4905): at
    android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2596)
    ERROR/AndroidRuntime(4905): at
    android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2621)
    ERROR/AndroidRuntime(4905): at
    android.app.ActivityThread.access$2200(ActivityThread.java:126)
    ERROR/AndroidRuntime(4905): at
    android.app.ActivityThread$H.handleMessage(ActivityThread.java:1932)
    ERROR/AndroidRuntime(4905): at
    android.os.Handler.dispatchMessage(Handler.java:99)
    ERROR/AndroidRuntime(4905): at android.os.Looper.loop(Looper.java:123)
    ERROR/AndroidRuntime(4905): at
    android.app.ActivityThread.main(ActivityThread.java:4595)
    ERROR/AndroidRuntime(4905): at
    java.lang.reflect.Method.invokeNative(Native Method)
    ERROR/AndroidRuntime(4905): at
    java.lang.reflect.Method.invoke(Method.java:521)
    ERROR/AndroidRuntime(4905): at
    com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
    ERROR/AndroidRuntime(4905): at
    com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
    ERROR/AndroidRuntime(4905): at dalvik.system.NativeStart.main(Native
    Method) ERROR/AndroidRuntime(4905): Caused by:
    java.lang.NullPointerException ERROR/AndroidRuntime(4905): at
    com.android.settings.bluetooth.BluetoothSettings.onCreate(BluetoothSettings.java:135)
    ERROR/AndroidRuntime(4905): at
    android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
    ERROR/AndroidRuntime(4905): at
    android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2544)
    ERROR/AndroidRuntime(4905): ... 11 more</p>
  </blockquote>
  
  <p>After investigating, I found that at line 135 in BluetoothSettings.java there is:</p>
  
  <pre><code>public class BluetoothSettings extends PreferenceActivity
  {
  
   ... 132 mNeedAuth = intent.getBooleanExtra(BluetoothDevicePicker.EXTRA_NEED_AUTH, false);
   133 mFilterType = intent.getIntExtra(BluetoothDevicePicker.EXTRA_FILTER_TYPE, 134 BluetoothDevicePicker.FILTER_TYPE_ALL);
   135 mLaunchPackage = intent.getStringExtra(BluetoothDevicePicker.EXTRA_LAUNCH_PACKAGE);
   136 mLaunchClass = intent.getStringExtra(BluetoothDevicePicker.EXTRA_LAUNCH_CLASS); ...
  </code></pre>
  
  <p>I looked into BluetoothDevicePicker to find the names of the extras:</p>
  
  <pre><code>public interface BluetoothDevicePicker { 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";
  public static final String EXTRA_LAUNCH_PACKAGE = "android.bluetooth.devicepicker.extra.LAUNCH_PACKAGE";
  public static final String EXTRA_LAUNCH_CLASS = "android.bluetooth.devicepicker.extra.DEVICE_PICKER_LAUNCH_CLASS";
  </code></pre>
  
  <p>So, I use them in my code to prepare those particular extras.</p>