I want to Print the name of all launched Activity name on a textView. Means If I run some activity manually eg
abcActivity.class, xyxActivity.class etc.
After that I have a button when I click on it, then it print the all Activity name in the following format:
Name of Launched Activity:
abcActivity
xyxActivity .
.
.
.
Button is in another Activity file...!!!
Here is what I think :
Create a public static ArrayList<String>
object in any one of the class so that you can use it in all other activities.
Now In onResume()
method, check whether the className exists, if yes then dont add className in arrayListObject. Otherwise add the className of current activity in arrayListObject using add method of arrayList ie arrayListObject.add(activityName);
.
You can get Class Name using :
#1 this.getClass().getName();
#2 Directly use "ABCActivity"
#3 context.getClassName();
Now you can use this arrayListObject to display all this values in TextView
.
Note : You will also have to take care of when the Activity1 is launching for the first time. At that time you will have to clear the arrayListObject and then have a fresh start.
For this I recommend you to go through the post : Application Launch Count
In your activity, onResume()
method add System.out (or) log statement this.getClass().getName();.
System.out.println(this.getClass().getName());
(or)
Log.d(this.getClass().getName(), "Insdie onResume");
use the log method for loggging data and printing it over logcat. You can put a line like this
Log.v(TAG,"abcActivity");
refer : http://developer.android.com/reference/android/util/Log.html
you can use
context.getClassName();
to get activity , service or BroadcastReceiver 's name.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.