How to access all applications process already running inside android phone and display them on screen on button click.
Any time inside android mobile phone there are lot’s of process running as background process because android is an fully loaded developed mobile phone operating system. Application developer can easily get background process using ActivityManager . So here is the complete step by step tutorial for Get Show All background running process in android programmatically.
How to Get Show All background running process in android programmatically.
Code for MainActivity.java file.
package com.showallbackgroundprocess_android_examples.com; import java.util.List; import android.app.Activity; import android.app.ActivityManager; import android.content.Context; import android.os.Bundle; import android.widget.TextView; public class MainActivity extends Activity { TextView textview; ActivityManager activitymanager; Context context; List<ActivityManager.RunningAppProcessInfo> RAP ; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); textview = (TextView)findViewById(R.id.textView1); context = getApplicationContext(); activitymanager = (ActivityManager)context.getSystemService(Context.ACTIVITY_SERVICE); RAP = activitymanager.getRunningAppProcesses(); for(ActivityManager.RunningAppProcessInfo processInfo: RAP ){ textview.setText(textview.getText() + processInfo.processName + "\n"); } } }
Code for activity_main.xml layout file.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context="com.showallbackgroundprocess_android_examples.com.MainActivity" android:orientation="vertical" > <ScrollView android:layout_width="wrap_content" android:layout_height="wrap_content" android:scrollbars="vertical" > <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Process Name" android:textSize="20dp" android:textColor="#010101" /> </LinearLayout> </ScrollView> </LinearLayout>
Screenshot: