I'm running my android app.
I want to enable push notifications only when app is not visible
(closed or in the background).
I have seen this code:
ActivityManager activityManager = (ActivityManager) this.getSystemService( ACTIVITY_SERVICE );
List<RunningAppProcessInfo> procInfos = actvityManager.getRunningAppProcesses();
for(int i = 0; i < procInfos.size(); i++){
if(procInfos.get(i).processName.equals("com.android.browser")) {
Toast.makeText(getApplicationContext(), "Browser is running", Toast.LENGTH_LONG).show();
}
}
for checking if the browser is on,
but it's not enough for me to check if the process is on,
it can be running but not visible at the moment,
and i want the notifications show in that case as oppose to when it's visible.