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

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -