{ "id": "171745", "key": "TIMOB-26099", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "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": { "id": "3", "description": "The problem is a duplicate of an existing issue.", "name": "Duplicate" }, "resolutiondate": "2018-06-06T22:05:09.000+0000", "created": "2018-06-05T22:28:13.000+0000", "priority": { "name": "Low", "id": "4" }, "labels": [ "android", "appc", "cli", "intent", "run" ], "versions": [], "issuelinks": [ { "id": "56574", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "outwardIssue": { "id": "171324", "key": "TIMOB-25867", "fields": { "summary": "Android: Running an application through CLI flickers it's main activity at launch.", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "priority": { "name": "Low", "id": "4" }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } } ], "assignee": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2018-06-06T22:05:09.000+0000", "status": { "description": "A resolution has been taken, and it is awaiting verification by reporter. From here issues are either reopened, or are closed.", "name": "Resolved", "id": "5", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "*Summary:*\r\n{{appc run}} launches the app on Android with an intent that is missing action \"android.intent.action.MAIN\" and category \"android.intent.category.LAUNCHER\", which is how an app is normally launched on Android via the app list screen.\r\n\r\nThe consequence of this is that if you press the HOME button to suspend the app and then tap on the app from the home screen, then a new activity instance will be created and Titanium will be stuck on the splash screen since Titanium only supports running 1 JavaScript runtime at a time.\r\n\r\n*Steps to reproduce:*\r\n# Build and run the below code on Android either via Appcelerator Studio or via {{appc run}} at the terminal.\r\n# Wait for the app to be displayed on the Android device.\r\n# Press the \"Home\" button to suspend the app. (Do *NOT* press the \"Back\" key.)\r\n# From the home screen, go to the app list screen.\r\n# Tap on the installed app to attempt to resume it.\r\n# After doing this, notice that the app is stuck displaying the splash screen. It does not resume the app. It has created a new activity instance without a JavaScript runtime.\r\n\r\n{code:javascript}\r\nvar window = Ti.UI.createWindow();\r\nwindow.add(Ti.UI.createLabel({ text: 'Test' }));\r\nwindow.open();\r\n{code}\r\n\r\n*Cause:*\r\nOn Android, an existing activity window stack can be resumed when using the same an intent that originally launched it. If given different intent settings for the same activity (such as the case here), then Android will create a new activity instance by default.\r\n\r\n*Recommended Solution:*\r\nWe need to modify the CLI on how it starts the app via Android \"adb\" command line tool here...\r\nhttps://github.com/appcelerator/node-titanium-sdk/blob/master/lib/adb.js#L655\r\n\r\nWe need to add intent parameters {{-a}} to set the action, {{-c}} to set the category, and {{-f}} to set the flags via adb similar to the following.\r\n{code}\r\n./adb shell am start -n /. -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000\r\n{code}\r\n\r\nThe {{-f 0x10200000}} part adds intent flags {{FLAG_ACTIVITY_NEW_TASK}} and {{FLAG_ACTIVITY_RESET_TASK_IF_NEEDED}}. The {{FLAG_ACTIVITY_NEW_TASK}} is set by all Android OS versions when launching an app from the home screen. The {{FLAG_ACTIVITY_RESET_TASK_IF_NEEDED}} is set by newer Android OS versions (such as Android 8) but works fine on older OS versions such Android 4.1.\r\n\r\n*Note:*\r\nWe also need this change to resolve a regression mentioned here: [TIMOB-25867]\r\n", "attachment": [], "flagged": false, "summary": "Android: CLI \"appc run\" should launch app with intent action MAIN category LAUNCHER", "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, "closedSprints": [ { "id": 1039, "state": "closed", "name": "2018 Sprint 12 SDK", "startDate": "2018-06-03T15:22:23.401Z", "endDate": "2018-06-17T15:22:00.000Z", "completeDate": "2018-06-18T20:45:36.363Z", "originBoardId": 114 } ], "comment": { "comments": [ { "id": "438156", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "body": "PR: https://github.com/appcelerator/node-titanium-sdk/pull/30", "updateAuthor": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-06-05T23:14:26.000+0000", "updated": "2018-06-05T23:15:10.000+0000" }, { "id": "438177", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "Marking as Duplicate of TIMOB-25867 to handle the regression fix there as well.", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-06-06T22:05:09.000+0000", "updated": "2018-06-06T22:05:09.000+0000" } ], "maxResults": 3, "total": 3, "startAt": 0 } } }