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

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -