How to get the android app detail like package name and others

2k Views Asked by At

I am working with MIT App Inventor and the activity starter component.

I have to know the app class, package detail and others, so how can I get all this information for any app?

Moreover I want to send SMS using activity starter from ICQ messenger to a specific contact. How can I do that?

3

There are 3 best solutions below

0
On

You can get this information from PackageManager:

        final PackageManager pm = context.getPackageManager();
        // get a list of installed apps.
        List<ApplicationInfo> packages = pm.getInstalledApplications(0);

        // loop through the list of installed packages and see if the selected
        // app is in the list
        for (ApplicationInfo packageInfo : packages) {

            //Get Package Name
            String packageName=packageInfo.packageName;

            // get the UID for the selected app
            int UID = packageInfo.uid;

            ApplicationInfo app = null;
            try {
                app = pm.getApplicationInfo(packageName, 0);
            } catch (PackageManager.NameNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

          //Get App Name
           String appName=pm.getApplicationLabel(app);

        //likewise you can get other information
        }
0
On

Here is the class name ApplicationInfo Developer doc link which gives you most of the detail of Application(installed in phone).

You can get list of Apps installed in the phone via below method.

PackageManager pm = getPackageManager();
List<ApplicationInfo> apps = pm.getInstalledApplications(0);

you can get applicatio info by looping above list. For packageName, can follow below code.

 for (ApplicationInfo packageInfo : apps) {
        //Package Name
        String temp =  packageInfo.packageName;
    }
0
On

For App Inventor this is explained in the documentation: Using the Activity Starter

Discovering how to set the ActivityStarter properties

If you want to start an app and you you don't have the source code or documentation, you might still be able figure out the package name and class name (and sometimes the intent) by launching the app and inspecting the Android system log. For example, if you use the YouTube application to play a video, you'll see in the log:

I/ActivityManager( 86): Starting activity: Intent { act=android.intent.action.VIEW dat=vnd.youtube:nAPk9ycCbfc cmp=com.google.android.youtube/.PlayerActivity }

If you can find the "cmp=" string, then the ActivityPackage is the part before the slash, e.g., com.google.android.youtube. The ActivityClass is is the entire "cmp=" part, without the slash character, e.g., com.google.android.youtube.PlayerActivity. There may also in general be "dat=" information that should be specify as the DataUri property.

How to use Logcat

I normally use Eclipse and Logcat there, but if you have installed the App Inventor Software (see also http://appinventor.mit.edu/explore/ai2/setup-emulator.html), you already have everything you need to use logcat...

  1. connect your device using USB with your computer in File Manger
  2. go to the App Inventor directory, which is C:\Program Files\App Inventor or similar
  3. press Shift and right mouse click the subdirectory commands-for-Appinventor to get the context menu
  4. select "open command window here" and you will get a command window of that subdirectory
  5. enter adb logcat and the logcat will start running