File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed
src/main/java/org/wordpress/android/util Expand file tree Collapse file tree 2 files changed +24
-0
lines changed File renamed without changes.
Original file line number Diff line number Diff line change 1+ package org .wordpress .android .util ;
2+
3+ import android .app .ActivityManager ;
4+ import android .app .ActivityManager .RunningTaskInfo ;
5+ import android .content .Context ;
6+
7+ import java .util .List ;
8+
9+ public class ActivityUtils {
10+ public static final String UNKNOWN = "unknown" ;
11+
12+ /**
13+ * Requires android.permission.GET_TASKS app permission
14+ */
15+ public static String getTopActivityClassName (Context context ) {
16+ ActivityManager am = (ActivityManager ) context .getSystemService (Context .ACTIVITY_SERVICE );
17+ // Get the most recent running task
18+ List <RunningTaskInfo > tasks = am .getRunningTasks (1 );
19+ if (tasks != null && tasks .get (0 ) != null && tasks .get (0 ).topActivity != null ) {
20+ return tasks .get (0 ).topActivity .getClassName ();
21+ }
22+ return UNKNOWN ;
23+ }
24+ }
You can’t perform that action at this time.
0 commit comments