How can get how many apps installed in my device and there names or last accessed information?

后端 未结 2 1876
眼角桃花
眼角桃花 2021-01-25 09:35

I need to show the last accessed app information in my app. How can i get this information?

2条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-25 09:59

    // How to detect which is the current top activity.

    public boolean whatIsCurrentActivity()  
    {  
     ActivityManager am = (ActivityManager) mContext.getSystemService(mContext.ACTIVITY_SERVICE);  
     List ActivityManager.RunningTaskInfo taskInfo = am.getRunningTasks(1);  
                   if(taskInfo != null ){  
                            System.out.println("Top activity - Package name of the process is "+taskInfo.get(0).topActivity.getPackageName() );  
           }  
    

提交回复
热议问题