Continuously refresh Bluetooth RSSI using AsyncTask
<p>I want to make the hand phone continuously refresh the RSSI values of other devices while the phone is being moved away from them.</p>

<p>In order to make the screen display keep updating the new RSSI values, I choose to use AsyncTask so as not to freeze my UI.</p>

<p>But somehow my code does not work. Every time it is run, the app dies. For debugging purpose, I put a Toast.makeText there. But nothing appears on the screen. So maybe that means my AsyncTask is actually not executed at all?</p>

<p>AsyncTask Codes:</p>

<pre><code>    private class Refresh extends AsyncTask&lt;Void, Void, Void&gt; {
    @Override
    protected Void doInBackground(Void... params) {
        // TODO Auto-generated method stub
        while(true){
            Toast.makeText(getApplicationContext(), "Loop is being executed", Toast.LENGTH_SHORT).show();
            init();
            startDiscovery();
        }
    }
}
</code></pre>

<p>OnCreat() Codes:</p>

<pre><code>@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    init();
    startDiscovery();

    new Refresh().execute();
}
</code></pre>

<p>Do please help me!
Where am I wrong?</p>

<p>ToT</p>
