Skip to content

Commit

Permalink
Merge pull request #458 from square/py/fix_npe
Browse files Browse the repository at this point in the history
Fix NPE
  • Loading branch information
jrodbx committed Mar 20, 2016
2 parents 462561d + efa41ac commit e5c0eee
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import com.squareup.leakcanary.CanaryLog;
import com.squareup.leakcanary.R;
import java.lang.reflect.Method;
import java.util.List;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;

Expand Down Expand Up @@ -114,10 +115,14 @@ public static boolean isInServiceProcess(Context context, Class<? extends Servic
ActivityManager activityManager =
(ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
ActivityManager.RunningAppProcessInfo myProcess = null;
for (ActivityManager.RunningAppProcessInfo process : activityManager.getRunningAppProcesses()) {
if (process.pid == myPid) {
myProcess = process;
break;
List<ActivityManager.RunningAppProcessInfo> runningProcesses =
activityManager.getRunningAppProcesses();
if (runningProcesses != null) {
for (ActivityManager.RunningAppProcessInfo process : runningProcesses) {
if (process.pid == myPid) {
myProcess = process;
break;
}
}
}
if (myProcess == null) {
Expand Down

0 comments on commit e5c0eee

Please sign in to comment.