2

My app shows a list of background running applications of the mobile device. When my app runs in kitkat device it is showing the list of background applications, but when it runs on marshmallow device it is showing only current app, not more than that.

Here is the main activity look like

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    TextView tv = (TextView) findViewById(R.id.text);

    ActivityManager activityManager = (ActivityManager) this
            .getSystemService(ACTIVITY_SERVICE);
    List<ActivityManager.RunningAppProcessInfo> procInfos = activityManager
            .getRunningAppProcesses();
    for (int idx = 0; idx < procInfos.size(); idx++) {
        tv.setText(tv.getText() + "" + (idx + 1) + "."
                + procInfos.get(idx).processName + "\n");
    }
}}

The permission that i have declared in manifeast.xml are

<uses-permission android:name="android.permission.GET_PACKAGE_SIZE" />
<uses-permission android:name="android.permission.CLEAR_APP_CACHE" />
<uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

left side is the kitkat device where i'm fetching all background running applications, where as right side is the marshmallow device i'm not able fetch the background running applications.

Karthik
  • 1,199
  • 2
  • 14
  • 23

0 Answers0