Commit 0cdd0faa by Kazuyuki Hida

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

parent f1eea383
......@@ -82,9 +82,22 @@ public class DeviceInfo {
ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
//noinspection deprecation(API21から非推奨になった。無視)
List<RunningTaskInfo> list = am.getRunningTasks(1);
if (list != null && list.size() > 0) {
ComponentName cn = list.get(0).topActivity;
if (cn != null) {
String name = cn.getPackageName();
return name.indexOf(context.getPackageName()) > -1;
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() {
......
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