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

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

    Details

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

      Description

      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.

      Solution:
      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.

      Use-Case:
      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.

      Note:
      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.

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:

                  Backbone Issue Sync

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

                    Git Source Code