Thanks for the quick reply.  What I mean "get an Activity object"
basically is getting a reference to that Activity, something like the
Instrumentation class does when it calls startActivitySync(), except
I'm not using Instrumentation.  For example:

Activity a = <what non-instrumentation API to use to get this>

Is this at all possible?  The reason I ask is because I notice that
some of the methonds of an Activity are declared public, and I want to
be able to access these methods from another class (that resides in
the same package as that Activity and resides in the same process, so
I'm not worried about security), but I can't do so unless I have a
reference to an Activity object.

Also, I don't want to start a new Activity.  I just want to be able to
access the methods that that Activity has from another class (for
example, if that class wants to terminate that Activity, I'd like to
do a.finish(), or (maybe this is a stretch) whether I can do something
like a.onCreateDescription() which is called from another class.

R

On Mar 10, 10:37 am, Mark Murphy <[email protected]> wrote:
> RCP2278 wrote:
> > First off, I apologize if this sounds like a trivial question with a
> > trivial answer, but I'm currently stuck at trying to get an Activity
> > object from ActivityManager or ComponentName.  I"ve been looking at
> > the android developer docs to see if there are any APIs exposed that I
> > can use so I can get an actual Activity object given that I have an
> > ActivityManager or ComponentName.  The best I can find so far is
> > grabbing the ComponentName from ActivityManager.RunningTaskInfo, get
> > the baseActivity (which is of type ComponentName), but then I'm stuck
> > there.  Can anyone help?
>
> What do you mean by "get an Activity object"?
>
> -- If you mean you want to start an Activity, I think a ComponentName
> can be used to construct an Intent.
>
> -- If you mean you want the actual object of an existing Activity...I
> don't think there is support in Android for that. Leastways, I've never
> seen it.
>
> -- If you mean something else, could you please clarify?
>
> Since the only Activity objects you could possibly access are your own,
> you could keep track of them yourself in some static HashMap or whatnot,
> but you'd have some bookkeeping to do to avoid garbage collection
> problems, handling multiple instances of the same Activity, etc.
>
> --
> Mark Murphy (a Commons 
> Guy)http://commonsware.com|http://twitter.com/commonsguy
>
> _The Busy Coder's Guide to *Advanced* Android Development_
> Version 1.3 Available!

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