Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-27070

Android: Add canStartActivity() method to "Ti.Android.Activity"


    • Type: New Feature
    • Status: Open
    • Priority: Medium
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Android
    • Story Points:


      The Issue:
      Currently, Titanium does not have an API to detect if there are any registered activities that can be started for a given intent. An app developer's only option is to call Titanium's startActivity() method and see if it throws an exception or not. This is an issue for apps that need to detect this in advance without launching an activity.

      Add a new canStartActivity(Intent) method to Ti.Android.Activity which will return true if at least 1 activity was found for the given intent.

      Internally, this should call Google's PackageManager.resolveActivity() method, where if it returns a non-null reference, then we know an activity exists for the given intent. Alternatively, we could call Google's PackageManager.queryIntentActivities() method which returns a list of activities matching the given intent, where we could check if at least 1 activity was returned.

      Can be used to detect if there is a 3rd party app installed for viewing a file, such as PDF. If canStartActivity() returns false, then you can alert the end-user that viewer app needs to be installed.

      While it would be more powerful to provide a queryIntentActivities() method in Titanium, the vast majority of app developers simply want to know if at least 1 activity exists. So, it's better to keep it simple for now. The only good use-case I've heard where you want to scrutinize the activity list is when you want to exclude an activity from a particular app that has known issues.


          Issue Links



              • Assignee:
                jquick Joshua Quick
                jquick Joshua Quick
              • Watchers:
                1 Start watching this issue


                • Created:

                  Backbone Issue Sync

                  • Backbone Issue Sync is enabled for your project, but we do not have any synchronization info for this issue.

                    Git Integration