{ "id": "173605", "key": "TIMOB-27070", "fields": { "issuetype": { "id": "2", "description": "A new feature of the product, which has yet to be developed.", "name": "New Feature", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [], "resolution": null, "resolutiondate": null, "created": "2019-05-08T18:34:38.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [ "activity", "android", "intent" ], "versions": [], "issuelinks": [ { "id": "57623", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "outwardIssue": { "id": "116157", "key": "TIMOB-14291", "fields": { "summary": "Android: Support for PackageManager and queryIntentActivities", "status": { "description": "The issue is open and ready for the assignee to start work on it.", "name": "Open", "id": "1", "statusCategory": { "id": 2, "key": "new", "colorName": "blue-gray", "name": "To Do" } }, "priority": { "name": "Low", "id": "4" }, "issuetype": { "id": "2", "description": "A new feature of the product, which has yet to be developed.", "name": "New Feature", "subtask": false } } } } ], "assignee": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2019-05-09T04:20:16.000+0000", "status": { "description": "The issue is open and ready for the assignee to start work on it.", "name": "Open", "id": "1", "statusCategory": { "id": 2, "key": "new", "colorName": "blue-gray", "name": "To Do" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "*The Issue:*\r\nCurrently, 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()|https://docs.appcelerator.com/platform/latest/#!/api/Titanium.Android.Activity-method-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.\r\n\r\n*Solution:*\r\nAdd a new {{canStartActivity(Intent)}} method to {{Ti.Android.Activity}} which will return {{true}} if at least 1 activity was found for the given intent.\r\n\r\nInternally, this should call Google's [PackageManager.resolveActivity()|https://developer.android.com/reference/android/content/pm/PackageManager.html#resolveActivity(android.content.Intent,%20int)] 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()|https://developer.android.com/reference/android/content/pm/PackageManager.html#queryIntentActivities(android.content.Intent,%20int)] method which returns a list of activities matching the given intent, where we could check if at least 1 activity was returned.\r\n\r\n*Use-Case:*\r\nCan 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.\r\n\r\n*Note:*\r\nWhile 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.", "attachment": [], "flagged": false, "summary": "Android: Add canStartActivity() method to \"Ti.Android.Activity\"", "creator": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "environment": null, "comment": { "comments": [], "maxResults": 0, "total": 0, "startAt": 0 } } }