Skip to content

Commit b008fb7

Browse files
committed
修复部分应用无法切换的问题
1 parent e3f4101 commit b008fb7

File tree

2 files changed

+16
-18
lines changed

2 files changed

+16
-18
lines changed

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/main/java/com/hardwork/fg607/relaxfinger/utils/AppUtils.java

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)