I am working on an application that requires to monitor MotionEvents
between activities of the application. It consists of a RootActivity
and a ChildActivity. The RootActivity will open the ChildActivity via
an intent which occurs at the moment the ACTION_DOWN event is
received. However, once the Child Activity is created the RootActivity
is suppose to react to the ACTION_UP that is to follow the ACTION_DOWN
that was used to create the ChildActivity. Below is a snippet of code
to help with the explaination. This code works fine up 1.6 of Android.
However, in 2.0 and above of Android the code no longer works and I am
unable to receive any MotionEvents on the RootActivity once the
ChildActivity has been created.

Questions:
- How can I recieve the corresponding ACTION_UP on the RootActivity
once the ChildActivity has been created?
- Is there any way to know using code the state of the screen to check
if it is being pressed or not?


Code:
public class RootActivity extends Activity implements OnTouchListener
{
      private ListView list;
      @Override
      protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.rootview);

         list = (ListView) findViewById(R.id.rootlist);
         list.setOnTouchListener(this);
      }

     @Override
     public boolean dispatchTouchEvent(MotionEvent ev) {
         // Print Log

         return super.dispatchTouchEvent(ev);
     }

    public boolean onTouch(View v, MotionEvent event) {
          switch( event.getAction() ) {
          case MotionEvent.ACTION_DOWN:
              Intent intent = new Intent(actions.CHILD_ACTIVITY)
              intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
              this.startActivity(inent);
              break;
          case MotionEvent.ACTION_UP:
              //Perform some other action
              break;
          }
          return true;
    }

}


-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to