Tag Archives: ComponentName

How to Check if your app is in Foreground or Background?

By | March 10, 2018

Here is a simple way to check if your app in running in Foreground or Background [java] private boolean isAppIsInBackground(Context context) { boolean isInBackground = true; ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT_WATCH) { List<ActivityManager.RunningAppProcessInfo> runningProcesses = am.getRunningAppProcesses(); for (ActivityManager.RunningAppProcessInfo processInfo : runningProcesses) { if (processInfo.importance == ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND) { for (String activeProcess : processInfo.pkgList) { if… Read More »

How to open wifi settings in android?

By | September 18, 2011

Hello all.. In today’s tutorial I will show you how to open the wifisettings in android programatically. This code comes handy when the user have not enabled the wifi and you want the user to enable it for your application to work. Here is the code for that. [java] package com.coderzheaven; import android.app.Activity; import android.content.ComponentName; import android.content.Intent; import… Read More »