This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
var gcm = require('node-gcm'); | |
var msgcall = new gcm.Message({ | |
data: { | |
key1: 'Pengyu Chen', | |
key2: 'Room 2' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static boolean isBackgroundRunning(Context context) { | |
ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); | |
List<ActivityManager.RunningAppProcessInfo> runningProcesses = am.getRunningAppProcesses(); | |
for (ActivityManager.RunningAppProcessInfo processInfo : runningProcesses) { | |
if (processInfo.importance == ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND) { | |
for (String activeProcess : processInfo.pkgList) { | |
if (activeProcess.equals(context.getPackageName())) { | |
//If your app is the process in foreground, then it's not in running in background | |
return false; | |
} |