android - Get instance of current visible activity -
how instance of visible activity in android? i've read can componentname of activity using activitymanager list of tasks , messing that, that's recipe disaster.
is there way instance of topmost activity, or if activity isn't mine , can't access it, null?
to instance of visible activity, context as:
context mcontext = getapplicationcontext();
or
mcontext = this;
now use activity related tasks.
or instance of activity; keep static activityclass instance somewhere else , use getter setter set instance like:
public void setactivity(myactivity activity) { myactivity = activity; } public myactivity getmyactivity() { return myactivity; }
Comments
Post a Comment