Android:Back key functionality
<p>In my android device there is no back key. So that I want to implement back button functionality using proximity sensor. When user tap on proximity of a device so that user should get previous activity. I implemented like this :</p>

<pre><code>SensorEventListener proxySensorEventListener = new SensorEventListener() {

            @Override
            public void onSensorChanged(SensorEvent event) {
                // TODO Auto-generated method stub

                if(event.sensor.getType()==Sensor.TYPE_PROXIMITY){              

                    //backByProxy();    

                    KeyEvent e = new KeyEvent(KeyEvent.ACTION_DOWN,KeyEvent.KEYCODE_BACK);                   
                    onKeyDown(KeyEvent.KEYCODE_BACK,e);  
                }

            }
</code></pre>

<p>In the above code I am explicitily calling Action_Down.</p>

<pre><code>@Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        // TODO Auto-generated method stub


         System.out.println("inside onKeyDown");

         if (keyCode == KeyEvent.KEYCODE_BACK) {
                moveTaskToBack(true);

                System.out.println("if****");

                return true;
            }
        return super.onKeyDown(keyCode, event);
    }
</code></pre>

<p>But problem is it is only working in my application. I want to work it globally means whichever the application activity is on foreground when user tap on proximity the previous activity should come to front(back button function). Is it possible. how to do this in android.</p>
