user2272890
user2272890

Reputation: 11

What is the Get_Tasks Permission and what is it used for?

I'm looking into developing apps for a project and I started researching permissions. I know the technical definition of GET_TASKS- Allows an application to get information about the currently or recently running tasks: a thumbnail representation of the tasks, what activities are running in it, etc. What I don't know is just what a "thumbnail" representation is- is it an actual picture (i.e screenshot of what is going on in another app), or is it just some information about the app? Also, what does the definition mean by "what activities are running in it"? Does that mean that someone can develop an app that can practically tell exactly what someone is doing, almost like a spy app (i.e if someone were checking their bank information on their browser, could the app see that?). Thanks for all the help, I'm a total noob here just trying to get used to the developer tools.

Upvotes: 1

Views: 1738

Answers (1)

maxweber
maxweber

Reputation: 576

It is used within the "context" of a Context... so, gives your Activities. E.g.

            Context context = this.hostActivity.getApplicationContext();
            ActivityManager am = (ActivityManager)context.getSystemService("activity");
            List taskInfo = null;
            try {
                 taskInfo = am.getRunningTasks(1);
                 if ((taskInfo != null) && (!taskInfo.isEmpty())) {
                   ComponentName topActivity = ((ActivityManager.RunningTaskInfo)taskInfo.get(0)).topActivity;
                   if (!topActivity.getPackageName().equals(context.getPackageName())) {
                     this.logger.debug("The application was displaced by new one.");
                     needPause = true;
                   } else {
                     this.logger.debug("The activity was displaced by new one in the same application.");
                   }
                 }
               } catch (SecurityException e) {
                 needPause = true;
                 this.logger.warn("The application has no GET_TASKS permission.");
               }

Upvotes: 1

Related Questions