Friday, April 18, 2014

Get in your own programs currently being displayed Activity how to do? I was a class.


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:
reference to the second floor shen332401890 reply:
oncreate when saving this

+1
Initialize your own use when saving the class constructor parameter passing
Reply:
cited a floor guoyoulei520 reply:
instance or activity you want to get the name

?
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 own
Reply:
reference to the 6th floor xiaanming 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 themselves change under

Good, thank you!

No comments:

Post a Comment