0

How do I get other app's thumbnails just like recent app does?

I found that this app can do so.

It seems that one can get thumbnail form framebuffer with root permission.

However, I'd like to know how to do this without root permission.

Thank you very much!

JohanLiebhart
  • 31
  • 1
  • 9

3 Answers3

0

You can do it with PackageManager. Nicely described in this answer:

https://stackoverflow.com/a/11277774/2829009

Community
  • 1
  • 1
Manuel Allenspach
  • 12,467
  • 14
  • 54
  • 76
0

First you have to get the list of the apps you installed.

final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
final List appsList = context.getPackageManager().queryIntentActivities( mainIntent, 0);

Then you can then call getIconResource() and get the icon resource of the install app.

For more info see ResolveInfo class.

istovatis
  • 1,408
  • 14
  • 27
  • Hi istovatis, Thanks for reply. What I am trying to get is not an icon but a thumbnail. It's like a screenshot for a running app. – JohanLiebhart Oct 11 '13 at 03:24
0

I finally knew we can use java reflection to call ActivityManagerNative.getTasks(int maxNum, int flags, IThumbnailReceiver receiver) to get other apps's thumbnails.

JohanLiebhart
  • 31
  • 1
  • 9
  • Great! Can you tell me how exactly did you called getTasks? I've tried something like [this](http://codepad.org/1ct1BO5y) but it's throwing a NoSuchMethodException. –  Nov 25 '13 at 11:11
  • Ok, and how did you imported the IThumbnailReceiver class? I think it should be in android.app but it isn't there.. –  Nov 28 '13 at 07:17
  • You can find IThumbnailReceiver.aidl in android source code. path: frameworks/base/core/java/android/app/IThumbnailReceiver.aidl. Just copy this file and put it in proper path in your apps. – JohanLiebhart Dec 03 '13 at 08:47
  • I get `java.lang.reflect.InvocationTargetException` on the last line in your code. – Alex Newman Apr 26 '16 at 18:36