How to send motion Event down to another activity

by sheng wang » Mon, 08 Feb 2010 09:50:45 GMT


Sponsored Links
 Hi,

My Activity using transparent Theme  in AndroidManifest.xml

*android:theme="@android:style/Theme.Translucent"*
*
*
Which works fine.  When it's started from the Home screen,   we can see both
 the content of  my activity  and the home screen below it.  It gives the
feeling of   "floating" .

Furthermore, to make it real "floating",  the motionEvent has to go down to
the home screen to let the home screen response some motion touch.
But I have no idea of 2 things :

1. Whether the event can be send down to any thing behind the current
activity.
2. If so, how. The solution don't need to be restricted in API level.  I
mean if  any solution need us to rewrite home screen or something else, It's
also ok for me.


Thanks for any suggestion.
Shawn.

--



How to send motion Event down to another activity

by Guobin » Mon, 08 Feb 2010 11:32:28 GMT


 > 1. Whether the event can be send down to any thing behind the current
No, you can't.
On the Android platform, you define an Activity's UI using a hierarchy
of View and ViewGroup nodes.
Home & your activity are different activity, they have their own view
hierarchy.
Key events are always delivered to the View currently in focus. They
are dispatched starting from the top of the View hierarchy, and then
down, until they reach the appropriate destination.
But not the view of other activity.
 http://developer.android.com/guide/topics/ui/ui-events.html 

Guobin

--


Sponsored Links


How to send motion Event down to another activity

by sheng wang » Mon, 08 Feb 2010 12:51:03 GMT


 Hi GuoBin,

I understand what u mean below. I think that's the standard way the android
deal with the event. Event goes through a current path within the activity.
No event will go out of the current activity.

As a surround way, is there any method that can let the current activity
find out who is behind him? so he  might communicate with the one behind
it?

Anyway, think you for taking your time to think the question.


Shawn.






2010/2/8 Guobin <zzg...@gmail.com>

>



How to send motion Event down to another activity

by Guobin » Mon, 08 Feb 2010 13:37:08 GMT


 1. Possibly there are ways to find the activity behind the current
one.
Precondition: All activity are fullscreen.
If your activity is the root activity, then Home is in behind.
Otherwise find the previous activity in the task stack.
2. You could send the touch event to other activity, but it's useless
I think.
The Android Window Mananger can only handle UI events for one view
hirarchy at one time.
May you send the event to the other activity, but no one can handle
it.

BRs
Guobin



> >



How to send motion Event down to another activity

by Streets Of Boston » Mon, 08 Feb 2010 23:47:49 GMT


 The activity that is no longer visible could have been destroyed by
the OS.
However, since your top-activity is (partially) translucent, this
probably won't happen.

If you really need to communicate back to the activity in the
background, there are various methods:

1. Use a static variable that holds the currently active 'background'
activity. Whenever you start your new 'foreground' activity, set this
static inside your 'background' activity and use it in your
'foreground' activity by calling one or more of its method.

2. Above won't work if your activities run in seperate process. If
this is the case, then you could use a background Service to deal with
the communication between the two activities.

But, be very careful with either of these approaches. Check or be
absolutely sure that this 'background' activity still exists...



> >



How to send motion Event down to another activity

by sheng wang » Tue, 09 Feb 2010 11:18:06 GMT


 Hi GuoBin,

1.  My translucent activity will be the root acitivity, and very possible
the home screen will be just behind, but what is the programmable way that
can  get a  activity  variable equals to the Home Launcher ?



2010/2/8 Guobin <zzg...@gmail.com>


1.  My translucent activity will be the root acitivity, and very possible
the home screen will be just behind, but what is the programmable way that
can  get a  activity  variable equals to the Home Launcher in my activity?



2.  In my understanding the activity behind in  OnResume status, but it's
still running.  I'm really not sure about that I will try some test on it .



> > >



How to send motion Event down to another activity

by Dianne Hackborn » Tue, 09 Feb 2010 12:48:35 GMT


 i,

You can't get the activity behind unless it is your own. Otherwise it is in
another process and untouchable by you.

There is only ever one activity resumed at a time, so if you are in the
front and resumed, then the home screen (or whatever) behind you is paused
(though not stopped because it is still visible).

The only way to let events get to the window behind yours is to make your
window not fullscreen, and set
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL to tell the window manager
that touches outside of your window should be delivered to whatever is
behind it.

On Mon, Feb 8, 2010 at 7:17 PM, sheng wang <banxia...@gmail.com> wrote:

>> > >



How to send motion Event down to another activity

by sheng wang » Tue, 09 Feb 2010 15:35:49 GMT


 i

About the "make your window not fullscreen". The activity starts full
screen. I remember some theme can make the activity not fullscreen. But it's
not so flexible, the floating window will be centered on the screen and can
not be moved(correct me if I'm wrong)

Besides the theme, are there any other way to make a activity not fullscreen
?



2010/2/9 Dianne Hackborn <hack...@android.com>

>>> > >



How to send motion Event down to another activity

by Dianne Hackborn » Tue, 09 Feb 2010 16:05:33 GMT


 ou can use the various options in WindowManager.LayoutParams to control how
your window is sized (you'll want WRAP_CONTENT to not be full screens),
where it is placed on screen (absolute position and/or gravity constants to
place relative to an edge), etc.

On Mon, Feb 8, 2010 at 11:34 PM, sheng wang <banxia...@gmail.com> wrote:

>>>> > >



How to send motion Event down to another activity

by Zhang Guobin » Tue, 09 Feb 2010 16:31:05 GMT


 Using Activity Manager, operating on the HistoryRecord list

Guobin

2010/2/9 sheng wang <banxia...@gmail.com>


>> > >



Other Threads

1. Android Lab Developer

Follow @isatdroid untuk live tweet dari event ekslusif by Google invitation
only: Android Developer Lab 2010 siang ini pukul 12 wib.

-- 
"Indonesian Android Community [id-android]" 

2. legitimate android market install VS adb -l

Hi,

Is there a way to detect if an application has been installed from the
market or simply pushed with ADB -l on a routed phone ?

-- 

3. Petition: Google, please improve the Android Market.

4. Any built-in intent for viewing a single image?

5. cropped picture with ImageView?

6. Obtain unicode string for Roslien Language

7. Is it possible to always use a custom Instrumentation?