dev
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
package com.mogo.utils;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-04-09
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class AppUtils {
|
||||
|
||||
public static boolean isApplicationBroughtToBackground( final Context context ) {
|
||||
ActivityManager am = ( ActivityManager ) context.getSystemService( Context.ACTIVITY_SERVICE );
|
||||
List< ActivityManager.RunningTaskInfo > tasks = am.getRunningTasks( 1 );
|
||||
if ( !tasks.isEmpty() ) {
|
||||
ComponentName topActivity = tasks.get( 0 ).topActivity;
|
||||
if ( !topActivity.getPackageName().equals( context.getPackageName() ) ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user