• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Help Unable to get User Action perform on Android screen

  • Thread starter Thread starter Android Question
  • Start date Start date
A

Android Question

Guest
Hello Team,

I want to get the user action performed on android screen like[touch,gestures] also get the resource property [resource -id, className] on performed object ,
I am able to get the user action only when user performed action on own created application.
below code shows a coordinates when user performed touch action on own my application Activity but not shows when i am minimize application and than touch on android screen

public class MainActivity extends Activity {

@override
protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

// on Create an application show a pop up message

Button buttonCancel = (Button) findViewById(R.id.button2);
startService(new Intent(MainActivity.this, MyServices.class));

buttonCancel.setOnClickListener(new Button.OnClickListener() {
@override
public void onClick(View arg0) {
stopService(new Intent(MainActivity.this, MyServices.class));

}
});
}

public boolean onTouchEvent(MotionEvent event) {
// MotionEvent object holds X-Y values
if(event.getAction() == MotionEvent.ACTION_DOWN) {
String text = "You click at x = " + event.getX() + " and y = " + event.getY();
Toast.makeText(this, text, Toast.LENGTH_LONG).show();
}

return super.onTouchEvent(event);
}

Any help will highly appreciated
 
Back
Top Bottom