Skip to content

Instantly share code, notes, and snippets.

@grantges
Last active June 3, 2016 17:26
Show Gist options
  • Save grantges/762d95bb3304501b46e7 to your computer and use it in GitHub Desktop.
Save grantges/762d95bb3304501b46e7 to your computer and use it in GitHub Desktop.
Appcelerator Titanium - Window Override
/**
* This file would go under the app/lib directory
*/
exports.createWindow = function(params){
var win = Ti.UI.createWindow(params);
win.addEventListener("open", function(e){
if(OS_ANDROID){
var activity = Ti.Android.activity ? Ti.Android.activity : Ti.Android.currentActivity;
activity.onStart =
activity.onResume =
activity.onRestart =
activity.onPause = function(e){
// DO SOMETHING
}
}
});
win.addEventListener("close", function(e){
if(OS_ANDROID){
var activity = Ti.Android.activity ? Ti.Android.activity : Ti.Android.currentActivity;
activity.onStart =
activity.onResume =
activity.onRestart =
activity.onPause = null;
}
});
};
<Alloy>
<Window module="apphooks" backgroundColor="#fff">
<Label>Hello World</Label>
</Window>
</Alloy>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment