I have a simple launcher that enlists all the apps in a listview. I just want one feature in this launcher; when a certain item(say 5th item) in the listview is clicked, I want to completely kill all the previous opened apps and then open the 5th app enlisted there. I don't know what should I look for. I have the launcher app as the device admin and device owner and I think that it has something to do with DevicePolicyManager
class. I also tried finishActivity(int requestcode) but it did not work. Below is the onItemClick() listener:
list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> av, View v, int pos,long id) {
Intent i = manager.getLaunchIntentForPackage(apps.get(pos).name.toString());
AppsListActivity.this.startActivity(i);
}
});