My class is to write their own, want to get the current program is currently Activity How to get it?
I have to call this class Dialog, requires an Activity to do setActivity.
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
You have to get the instance or activity of the name?
Reply:
oncreate save this time
Reply:
+1
Initialize your own use when saving the class constructor parameter passing
Reply:
?
Get his Activity instance.
I need it for an instance of this class is to call startActivity.
Reply:
Rewriting the new class constructor, passing in context to try?
Reply:
public boolean isTopActivy (String cmdName) {
ActivityManager manager = (ActivityManager) context.getSystemService (ACTIVITY_SERVICE);
List runningTaskInfos = manager.getRunningTasks (1);
String cmpNameTemp = null;
if (null! = runningTaskInfos) {
cmpNameTemp = (runningTaskInfos.get (0) topActivity.) toString);.
Log.e ("cmpname", "cmpname:" + cmpName);
}
if (null == cmpNameTemp) return false;
return cmpNameTemp.equals (cmdName);
} check the stack of Activity, the landlord changed under their ownReply:
Good, thank you!
No comments:
Post a Comment