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, the
RootActivity is suppose to perform some action upon receiving the
corresponding 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 explanation. This code works fine up to 1.6 of Android.
However, in 2.0 and above of Android this 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.CREATE_CHILD_ACTIVITY);
              intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
              this.startActivity(intent);
              break;
          case MotionEvent.ACTION_UP:
              //Perform some 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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to