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
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