[TIMOB-13339] Android: Add support for onUserLeaveHint for activities
GitHub Issue | n/a |
---|---|
Type | New Feature |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2013-09-09T20:50:09.000+0000 |
Affected Version/s | n/a |
Fix Version/s | 2013 Sprint 19, 2013 Sprint 19 API, Release 3.2.0 |
Components | Android |
Labels | community, module_api, qe-testadded |
Reporter | Jesper Jonsson |
Assignee | Sunila |
Created | 2013-02-28T15:44:47.000+0000 |
Updated | 2013-10-23T23:15:19.000+0000 |
Description
There isn't any good way to know if the user "pauses" an Android app. For example by hitting the home button. Listening for activity pause/resume for a multiple activity app can be really messy.
Maybe also hook this feature into the Ti.App.pause(d) event?
http://developer.android.com/reference/android/app/Activity.html#onUserLeaveHint()
var win = Ti.UI.createWindow({
backgroundColor : 'red',
orientationModes : [Titanium.UI.PORTRAIT],
exitOnClose : true,
navBarHidden : true
});
win.addEventListener('open', function(){
win.getActivity().addEventListener('userleavehint', function()
{
Ti.API.info("Activity USER_LEAVE_HINT!!!!");
});
});
win.addEventListener('click', function()
{
var secondWin = Ti.UI.createWindow({
backgroundColor : 'blue',
orientationModes : [Titanium.UI.PORTRAIT],
navBarHidden : true
});
secondWin.open();
});
win.open();
Pause/resume should only be called when you leave the app, for example pressing the home buttom.
This event is for the activity and will be fired when the activity goes to the background when opening the 'secondWin' which won't help providing the 'app' 'pause' event.
A new event 'userleavehint' is added to the activity https://github.com/appcelerator/titanium_mobile/pull/4647
Verified fix on: Device : HTC desire V , Android version : 4.0.3 SDK: 3.2.0.v20131008154043 CLI version : 3.2.0 OS : MAC OSX 10.8.4 Alloy : 1.2.2 Appcelerator Studio, build: 3.2.0.201310092427 XCode : 5