how to let activity work in background after click back button
<p>I'm using Activity to get data permanently from vehicule using BLE <code>BluetoothLeService</code> like (vehicule speed, temperature, etc) and inject it to <code>Sqlite DataBase</code> in real time,
until there it works perfectly.</p>

<p>My problem is that when i press key back to return to my principle activity i want to keep the scanning.</p>

<p>So i tried to override <code>onKeyDown</code> like the following but when i click keyBack the scanning still working but it puts all the application <code>onBackground</code> not only the activity.</p>

<pre><code>@Override
public boolean onKeyDown(int keyCode, KeyEvent event)
{
    switch(keyCode)
    {
        case KeyEvent.KEYCODE_BACK:
            moveTaskToBack(true);
            return true;
    }
    return false;
}
</code></pre>

<p>I tried also to put <code>moveTaskToBack(true)</code> inside <code>onStop</code> and when i click keyBack the scanning getting stoped.</p>

<p>i've searched a lot and tried a several solutions but still not working. Any suggestions or other ideas i'll appreciate it.</p>