natehoch96
natehoch96

Reputation: 69

Find package and activity names of system apps?

How would I go about finding the package names and main activity name for system apps on motoblur and touchwiz? I am making an app but I want it to be universal, not just Sense and stock android. I dont actually own a phone running touchwiz or motoblur so I am stumped on how to find them out. Thanks

Upvotes: 1

Views: 4177

Answers (2)

Peter Knego
Peter Knego

Reputation: 80340

Note that you should not start activities via package/class names - system apps vary from device to device AND activity class names might change with app updates (I noticed Google Maps did this once).

The other reason would be that users might prefer to use some other app they installed to do particular task (for example I prefer to take pictures with a 3rd party app).

You should invoke apps via system defined intents.

Upvotes: 1

Nikola Despotoski
Nikola Despotoski

Reputation: 50538

You need to gather info about installed apps on the phone than go through the list and search for desired activity

   PackageManager packmngr = this.getPackageManager(); 
    Intent ints = new Intent(Intent.ACTION_MAIN, null)
    ints.addCategory(Intent.CATEGORY_LAUNCHER); 
    List<ResolveInfo> list = packmngr.queryIntentActivities(ints, PackageManager.PERMISSION_GRANTED); 

ints.addCategory(Intent.CATEGORY_LAUNCHER); <--- Here you can specify what type of Intent (which the developer of the other app defined in the manifest) to search with the query, it can by either CATEGORY_LAUNCHER or CATEGORY_DEFAULT, actually the main activities are of type CATEGORY_LAUNCHER.

And the trivial iteration in the list:

       for(ResolveInfo rlnfo: list)
        {
             //Adjust the code and do tests within here.
            Log.i("ACTIVITY INFO: ", rlnfo.activityInfo.toString());
            Log.i("ACTIVITY NAME: ",rlnfo.resolvePackageName.toString());
        }

Check here for more info about constants and methods: http://developer.android.com/reference/android/content/pm/PackageManager.html

Upvotes: 0

Related Questions