Android Studio - setAdapter() - fails
<p>I try to make Bluetooth app and a run into troubles with <code>setAdapter()</code>.</p>

<pre><code>private BluetoothAdapter BA;
ListView listB;
private Set&lt;BluetoothDevice&gt; pairedDevices;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    BA = BluetoothAdapter.getDefaultAdapter();
    listB = (ListView)findViewById(R.id.listBlu);
    if (!BA.isEnabled()) {
        Intent blu_turn_on = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
        startActivityForResult(blu_turn_on, 0);
        Toast.makeText(getApplicationContext(),"Bluetooth turn on",Toast.LENGTH_SHORT).show();
        Set&lt;BluetoothDevice&gt; pariedDevices;
        pariedDevices = BA.getBondedDevices();
    }
    else
    {
        Toast.makeText(getApplicationContext(),"Bluetooth already on", Toast.LENGTH_SHORT).show();
    }
    Intent getVisible = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
    startActivityForResult(getVisible, 0);
    pairedDevices = BA.getBondedDevices();
    ArrayList list = new ArrayList();

    for(BluetoothDevice bt : pairedDevices)
        list.add(bt.getName());
    Toast.makeText(getApplicationContext(),"Showing Paired Devices",Toast.LENGTH_SHORT).show();

    final ListAdapter adapter = new ArrayAdapter(this,android.R.layout.simple_list_item_1, list);
    listB.setAdapter(adapter);
}
</code></pre>

<p><code>04-20 21:52:15.761 17597-17597/com.example.werewolf.deltacontroler W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
04-20 21:52:16.074 17597-17765/com.example.werewolf.deltacontroler D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
04-20 21:52:16.085 17597-17597/com.example.werewolf.deltacontroler D/Atlas: Validating map...
04-20 21:52:16.201 17597-17765/com.example.werewolf.deltacontroler I/Adreno-EGL: &lt;qeglDrvAPI_eglInitialize:410&gt;: EGL 1.4 QUALCOMM build: AU_LINUX_ANDROID_LA.AF.1.1_RB1.05.00.02.006.020_msm8960_LA.AF.1.1_RB1__release_AU ()
                                                                                 OpenGL ES Shader Compiler Version: E031.25.03.06
                                                                                 Build Date: 05/22/15 Fri
                                                                                 Local Branch: mybranch10237523
                                                                                 Remote Branch: quic/LA.AF.1.1_rb1.18
                                                                                 Local Patches: NONE
                                                                                 Reconstruct Branch: AU_LINUX_ANDROID_LA.AF.1.1_RB1.05.00.02.006.020 + 9b2699f + 2215637 + 60aa592 + f2362e6 + 5c64f59 + 82411a1 + 89a0db6 + 6151be1 +  NOTHING
04-20 21:52:16.210 17597-17765/com.example.werewolf.deltacontroler I/OpenGLRenderer: Initialized EGL, version 1.4
04-20 21:52:16.260 17597-17765/com.example.werewolf.deltacontroler D/OpenGLRenderer: Enabling debug mode 0
04-20 21:52:16.535 17597-17597/com.example.werewolf.deltacontroler I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@31ae5690 time:79315035
04-20 21:52:42.340 17597-17597/com.example.werewolf.deltacontroler I/Timeline: Timeline: Activity_launch_request id:com.example.werewolf.deltacontroler time:79340840
04-20 21:52:42.495 17597-17597/com.example.werewolf.deltacontroler D/BluetoothAdapter: 850763313: getState() :  mService = null. Returning STATE_OFF
04-20 21:52:42.501 17597-17597/com.example.werewolf.deltacontroler D/BluetoothAdapter: 850763313: getState() :  mService = null. Returning STATE_OFF
04-20 21:52:42.507 17597-17597/com.example.werewolf.deltacontroler D/AndroidRuntime: Shutting down VM
04-20 21:52:42.514 17597-17597/com.example.werewolf.deltacontroler E/AndroidRuntime: FATAL EXCEPTION: main
                                                                                     Process: com.example.werewolf.deltacontroler, PID: 17597
                                                                                     java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.werewolf.deltacontroler/com.example.werewolf.deltacontroler.Configuration}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ListView.setAdapter(android.widget.ListAdapter)' on a null object reference
                                                                                         at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379)
                                                                                         at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2442)
                                                                                         at android.app.ActivityThread.access$800(ActivityThread.java:156)
                                                                                         at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1351)
                                                                                         at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                         at android.os.Looper.loop(Looper.java:211)
                                                                                         at android.app.ActivityThread.main(ActivityThread.java:5389)
                                                                                         at java.lang.reflect.Method.invoke(Native Method)
                                                                                         at java.lang.reflect.Method.invoke(Method.java:372)
                                                                                         at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1020)
                                                                                         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:815)
                                                                                      Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ListView.setAdapter(android.widget.ListAdapter)' on a null object reference
                                                                                         at com.example.werewolf.deltacontroler.Configuration.onCreate(Configuration.java:51)
                                                                                         at android.app.Activity.performCreate(Activity.java:5990)
                                                                                         at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
                                                                                         at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2332)
                                                                                         at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2442) 
                                                                                         at android.app.ActivityThread.access$800(ActivityThread.java:156) 
                                                                                         at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1351) 
                                                                                         at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                                         at android.os.Looper.loop(Looper.java:211) 
                                                                                         at android.app.ActivityThread.main(ActivityThread.java:5389) 
                                                                                         at java.lang.reflect.Method.invoke(Native Method) 
                                                                                         at java.lang.reflect.Method.invoke(Method.java:372) 
                                                                                         at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1020) 
                                                                                         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:815) 
04-20 21:52:49.245 18952-18952/com.example.werewolf.deltacontroler I/Process: Sending signal. PID: 18952 SIG: 9
04-20 21:52:49.512 19066-19066/com.example.werewolf.deltacontroler W/ResourceType: Found multiple library tables, ignoring...
04-20 21:52:49.522 19066-19066/com.example.werewolf.deltacontroler W/ResourceType: Found multiple library tables, ignoring...
04-20 21:52:49.859 19066-19066/com.example.werewolf.deltacontroler W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
04-20 21:52:50.172 19066-19066/com.example.werewolf.deltacontroler D/BluetoothAdapter: 132902748: getState() :  mService = null. Returning STATE_OFF
04-20 21:52:50.194 19066-19066/com.example.werewolf.deltacontroler D/BluetoothAdapter: 132902748: getState() :  mService = null. Returning STATE_OFF
04-20 21:52:50.206 19066-19066/com.example.werewolf.deltacontroler D/AndroidRuntime: Shutting down VM
04-20 21:52:50.208 19066-19066/com.example.werewolf.deltacontroler E/AndroidRuntime: FATAL EXCEPTION: main
                                                                                     Process: com.example.werewolf.deltacontroler, PID: 19066
                                                                                     java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.werewolf.deltacontroler/com.example.werewolf.deltacontroler.Configuration}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ListView.setAdapter(android.widget.ListAdapter)' on a null object reference
                                                                                         at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379)
                                                                                         at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2442)
                                                                                         at android.app.ActivityThread.access$800(ActivityThread.java:156)
                                                                                         at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1351)
                                                                                         at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                         at android.os.Looper.loop(Looper.java:211)
                                                                                         at android.app.ActivityThread.main(ActivityThread.java:5389)
                                                                                         at java.lang.reflect.Method.invoke(Native Method)
                                                                                         at java.lang.reflect.Method.invoke(Method.java:372)
                                                                                         at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1020)
                                                                                         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:815)
                                                                                      Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ListView.setAdapter(android.widget.ListAdapter)' on a null object reference
                                                                                         at com.example.werewolf.deltacontroler.Configuration.onCreate(Configuration.java:51)
                                                                                         at android.app.Activity.performCreate(Activity.java:5990)
                                                                                         at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
                                                                                         at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2332)
                                                                                         at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2442) 
                                                                                         at android.app.ActivityThread.access$800(ActivityThread.java:156) 
                                                                                         at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1351) 
                                                                                         at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                                         at android.os.Looper.loop(Looper.java:211) 
                                                                                         at android.app.ActivityThread.main(ActivityThread.java:5389) 
                                                                                         at java.lang.reflect.Method.invoke(Native Method) 
                                                                                         at java.lang.reflect.Method.invoke(Method.java:372) 
                                                                                         at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1020) 
                                                                                         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:815) 
04-20 21:52:51.591 19066-19066/com.example.werewolf.deltacontroler I/Process: Sending signal. PID: 19066 SIG: 9</code></p>

<p>App working fine, but as soon as enter this part of code it crashes.
<br/> The problem is in last line with <code>setAdapter()</code>, because if I removed it from code app run just normally giving in result empty window.<br/>
I tried to look for solution, but it seems that everybody do it similar way, and I can't spot my mistake.</p>