views:

43

answers:

1

Applications can have any number of launchable activities. I know how to get the list of these activities via PackageManager.

Is there a way to determine which activities can be launched via startActivity?

For example, the Documents To Go app has different activities that will start Word, Excel, Powerpoint, PDF, etc... I am able to launch all o these just fine.

However, it also contains some activities that I am not able to launch with startActivity... If I attempt to do this I get a SecurityException.

I want to be able to determine which activities I can safely launch and which I cannot so I only present the user with a list of activities that I can safely launch from within my application...

Is this possible?

A: 

Create the intent with the parameters/data that you have and then use the package manager resolveActivity() method to check for the activity which will be process your request.

Then check the permissions using checkPermission() method of PackageManager.

HTH !

Karan
Thank you! I will look into that...
Justin
Unfortunately, the resolveActivity() method is only for implicit intents. Since I have the package and class names for the activities I am launching (I am getting them through PackageManager) this method will not work for what I want to do.I'm not having a problem FINDING the activity to launch. The problem is that when I attempt to launch it via startActivity() I get a SecurityException error...Any other suggestions are welcome.
Justin
For what it's worth, the exact error I am getting from the SecurityException is this: Permission Denial: starting Intent { flg=0x10600000 cmp=com.dataviz.docstogo/com.dataviz.dxtg.common.android.WelcomeScreenActivity } from ProcessRecord{43565cb0 14660:com.magouyaware.appswipe/10043} (pid=14660, uid=10043) requires null
Justin
However, I can successfully launch other activities provided by the Docs To Go application. So the question is, how can I determine which ones I can and cannot launch... (Note that using Docs To Go is just an example... This exact same problem ocurrs with many different apps)
Justin