I have :-
Class Abc extends Activity(){
private ActivityManager am;
private List<RunningAppProcessInfo> rList;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
@Override
public void onStart (Bundle savedInstanceState) {
super.onStart(savedInstanceState);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
super.onTouchEvent(event);
rList= am.getRunningAppProcesses();
Log.e("MAIN", rList.isEmpty() +" .");
return true;
}
}
am.getRunningAppProcesses() is always null even though i have foreground apps running, the active applications also shows them correctly. i know that its supposed to return null if there’s nothing else running, but i launch other apps (gmail, camera, for testing)
Is this a permissions issue?
figured it out.
For
ActivityManager am, since the constructor isprivate, and nostaticinstances are available, it must be instantiated like:am = (ActivityManager)getSystemService(ACTIVITY_SERVICE);Hope this is useful to someone stuck with a similar problem