获取当前运行的Activity信息

new Thread(new Runnable() {
@Override
public void run() {

while(true){
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
ActivityManager.RunningTaskInfo info = manager.getRunningTasks(1).get(0);
String shortClassName = info.topActivity.getShortClassName(); //类名
String className = info.topActivity.getClassName(); //完整类名
String packageName = info.topActivity.getPackageName(); //包名
Log.e("class",className+packageName+shortClassName);
}

}
}).start();

posted on 2017-03-14 11:45  yaolunhui  阅读(351)  评论(0编辑  收藏  举报

导航