Android Studio 检查Top Activity

  public void CheckTop(String packagename,int casenum)
    {
        Context context = getBaseContext();
        ActivityManager am = (ActivityManager) context.
                getSystemService(Activity.ACTIVITY_SERVICE);

        String className = am.getRunningTasks(1).get(0).topActivity.getClassName();
        if(!className.contains(packagename) )
        {
            lo
            Log.d("TAG", " Test fail...");
        }
        else
        {
            Log.d("TAG", " Test pass...");
        }
    }

  

你可能感兴趣的:(Android Studio 检查Top Activity)