diff --git a/CHANGELOG.md b/CHANGELOG.md index f213c0c30..c4c46ce21 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ### Development Bug Fixes: + - Fix NullPointerException in ProcessUtils. (#598, David G. Young) - Fix ConcurrentModificationException crashing app on Android 8 when monitored regions are changed at the same time the app shifts from active scanning to passive scanning. (#578, David G. Young) diff --git a/src/main/java/org/altbeacon/beacon/utils/ProcessUtils.java b/src/main/java/org/altbeacon/beacon/utils/ProcessUtils.java index f0ffb0d70..7cf0959c5 100644 --- a/src/main/java/org/altbeacon/beacon/utils/ProcessUtils.java +++ b/src/main/java/org/altbeacon/beacon/utils/ProcessUtils.java @@ -4,6 +4,8 @@ import android.content.Context; import android.support.annotation.NonNull; +import java.util.List; + /** * Created by dyoung on 3/10/17. * @@ -20,9 +22,12 @@ public ProcessUtils(@NonNull Context context) { public String getProcessName() { ActivityManager manager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE); - for (ActivityManager.RunningAppProcessInfo processInfo : manager.getRunningAppProcesses()) { - if (processInfo.pid == getPid()) { - return processInfo.processName; + List processes = manager.getRunningAppProcesses(); + if (processes != null) { + for (ActivityManager.RunningAppProcessInfo processInfo : processes) { + if (processInfo.pid == getPid()) { + return processInfo.processName; + } } } return null;