3

I want to Print the name of all launched Activity name on a textView. Means If I run some activity manually e.g.

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...!!!

Android Boy
  • 4,335
  • 6
  • 30
  • 58

4 Answers4

5

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

Community
  • 1
  • 1
Kartik Domadiya
  • 29,868
  • 19
  • 93
  • 104
0

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");
kosa
  • 65,990
  • 13
  • 130
  • 167
0

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

Amol Gupta
  • 704
  • 1
  • 8
  • 26
0

you can use

context.getClassName(); to get activity, service or BroadcastReceiver's name.

Uniruddh
  • 4,427
  • 3
  • 52
  • 86
jeet
  • 29,001
  • 6
  • 52
  • 53