@@ -309,31 +309,29 @@ public static String getPreviousNew() throws Exception {
309309 }
310310 ActivityManager am = (ActivityManager ) context .getSystemService (Context .ACTIVITY_SERVICE );
311311 List <ActivityManager .RunningAppProcessInfo > appList = am .getRunningAppProcesses ();
312- for (ActivityManager .RunningAppProcessInfo app : appList ) {
313- if (app .importance != ActivityManager .RunningAppProcessInfo .IMPORTANCE_FOREGROUND
314- && app .importanceReasonCode == ActivityManager .RunningAppProcessInfo .REASON_UNKNOWN ) {
315- Integer state = null ;
316- try {
317- state = field .getInt (app );
318- } catch (Exception e ) {
319- }
320-
321- if (state != null ) {
322- ApplicationInfo info = getApplicationInfoByProcessName (app .processName );
312+ //i=1从第二个检索,因为第一个是当前app
313+ for (int i = 1 ; i < appList .size (); i ++) {
314+ Integer state = null ;
315+ try {
316+ state = field .getInt (appList .get (i ));
317+ } catch (Exception e ) {
318+ }
323319
324- if ( info != null && ! info . packageName . equals ( "com.hardwork.fg607.relaxfinger" )) {
325- Log . i ( "task" , info . packageName );
320+ if ( state != null ) {
321+ ApplicationInfo info = getApplicationInfoByProcessName ( appList . get ( i ). processName );
326322
327- Intent intent = pm . getLaunchIntentForPackage ( info .packageName );
323+ if ( info != null && ! info .packageName . equals ( "com.hardwork.fg607.relaxfinger" )) {
328324
329- if ( intent != null ){
325+ Intent intent = pm . getLaunchIntentForPackage ( info . packageName );
330326
331- return info .packageName ;
332- }
327+ if (intent != null ) {
333328
329+ //Log.i("background", info.packageName);
330+ return info .packageName ;
334331 }
335332
336333 }
334+
337335 }
338336 }
339337
0 commit comments