android - How Get a list of current running APP in Anrdroid -
i want use activitymanager list of current apps , return newest process` name system clipboard.just this
protected void onstart() { super.onstart(); amanager=(activitymanager)this.getsystemservice(activity_service); activitymanager.runningappprocessinfo app=null; list<activitymanager.runningappprocessinfo> runningtasks; try { runningtasks = amanager.getrunningappprocesses(); app = runningtasks.get(0); }catch (final exception e){log.d(tag, "list error");} if(app!=null) { string result =app.processname; contenttext.settext(result);; clipboard.settext(result); }else { log.d(tag, "component error"); } }
but when running @ simulator, errors occured:
java.lang.runtimeexception: unable start activity componentinfo{//the absolute address}:
try
activitymanager actvitymanager = (activitymanager) this.getsystemservice( activity_service ); list<runningappprocessinfo> procinfos = actvitymanager.getrunningappprocesses(); for(int = 0; < procinfos.size(); i++) { log.i("app-package","" + procinfos.get(i).processname); }
this may helps you
Comments
Post a Comment