Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Move <code>GetPairedDevices();</code> into your <code>onActivityResult()</code></p> <p>Somthing like</p> <pre><code> @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { // TODO Auto-generated method stub //super.onActivityResult(requestCode, resultCode, data); if (resultCode == RESULT_CANCELED){ Toast.makeText(getApplicationContext(), "too bad..", Toast.LENGTH_LONG).show(); finish(); } else if (resultCode == RESULT_OK) { GetPairedDevices(); } </code></pre> <p>this way <code>onCreate()</code> can finish and that function will only run if you enable bluetooth, which I believe is what you want</p> <p>If you want it to run if Bluetooth is enabled and not <code>null</code> in <code>onCreate()</code> then you may want to change your <code>onCreate()</code> to something like</p> <pre><code> @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); init(); if (BtAdapter==null){ Toast.makeText(getApplicationContext(), "No Bluetooth adapter...",0 ).show(); finish(); } elseif (BtAdapter != null &amp;&amp; !BtAdapter.isEnabled()){ Intent intent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); startActivityForResult(intent, 1); } else{ GetPairedDevices(); } } </code></pre> <p><strong>Note:</strong></p> <p>This was just a quick example of how you need to do it because <code>onCreate()</code> is going to finish executing the remaining code in the function. I haven't tested it or know all of your code but something like this should help.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload