Commit 5a6ba1fc by Kazuyuki Hida

NullPointerExceptionの発生源にnullチェックを入れた。

parent c3c89a45
...@@ -80,9 +80,22 @@ public class DeviceInfo { ...@@ -80,9 +80,22 @@ public class DeviceInfo {
ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
//noinspection deprecation(API21から非推奨になった。無視) //noinspection deprecation(API21から非推奨になった。無視)
List<RunningTaskInfo> list = am.getRunningTasks(1); List<RunningTaskInfo> list = am.getRunningTasks(1);
ComponentName cn = list.get(0).topActivity; if (list != null && list.size() > 0) {
String name = cn.getPackageName(); ComponentName cn = list.get(0).topActivity;
return name.indexOf(context.getPackageName()) > -1; if (cn != null) {
String name = cn.getPackageName();
if (name != null) {
return name.contains(context.getPackageName());
} else {
Logger.d(TAG, "packageName is null");
}
} else {
Logger.d(TAG, "ComponentName is null");
}
} else {
Logger.d(TAG, "getRunningTasks is empty");
}
return false;
} }
private static boolean isEmulator() { private static boolean isEmulator() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment