Please could you explain how I can detect when an app is closed? I don't want to use only OnSleep as this is only background running, so it there a method for identifying when an app is exited in contract to the OnStart method?
Does OnDisappearing AND OnAppearing work just the same?
Thanks
Related
I have an app that opens other part of the app inside the webview, but I need to turn off the warning of switching apps. The idea is to the user to just open another part of the app when he clicks the page inside the webview. Anyone has any thoughts?
Thanks in advance.
I'm working on inactivity detection.
I have successfully done so in iOS by subclassing UIApplication and overriding SendEvent as outlined here.
I know I could implement this separately for both iOS and Android, but I'd rather have a cross-platform Forms approach by intercepting all touch events and resetting my timers. I'd rather not have to add a touch event handler to all my pages either.
I was unable to find a cross platform approach. I was able to accomplish this by leaving the timer related information in core Forms project and implement the touch event handlers separately for iOS and Android. I handled the iOS touch events as outlined in the link in the OP, but for Android I took the approach of subclassing Activity due to the presence of the OnUserInteraction() method.
Initially I thought I would have to force Xamarin to use my subclassed Activity for all pages that I use in Xamarin, but I was mistaken. AdamMeaney over on the Xamarin forums was able to help with providing a solution for the Android side of things with regards to subclassing an Android activity. As it turns out, Xamarin only uses one Activity which inherits from Xamarin.Forms.Platform.Android.FormsAppCompatActivity. I used the MainAcitivty provided by Xamarin in the Droid project. From there, overriding the OnUserInteraction() proved to be quite simple:
public override void OnUserInteraction()
{
base.OnUserInteraction();
//Do other stuff
}
It would seem to me that all you really have to do on the platform side is get notified whenever a new touch event occurs. Unless I am missing something it seems you can do all of the timer stuff in the PCL core Forms project and call that code from the platform specific code that runs when a touch is detected.
So if on Android ( I did not verify, but I would assume so) there is a similar way to handle any touch, device wide, then it would seem that all you have to do is implement that event handler, as you did for iOS, and call into your Forms core code to handle the timer(s).
To clarify: On the platform side, just handle the touch events globally and then call into code in the Forms core thus only having to implement the timer functionality once. Or so it would seem unless I am missing something.
If you want to make a feature request for Xamarin Form, please do so at Xamarin's user voice page: xamarin.uservoice.com
I suspect Forms would just have to do as outlined above... handle device wide touches on each platform and then have a virtual method in Forms core code that is called whenever a touch occurs.
I'm pretty new to Appcelerator and was wondering what the listeners for the view life cycle are?
For example, if I wanted to detect the iOS viewWillAppear and viewDidDisappear methods, or Androids OnResume, OnPause methods, then how would I do this the "Appcelerator" way?
I've searched around on the web, but only able to find in the Titanium documentation info about the application state such as Active, Suspended, ect. I need a controller, or window, specific listener to react to.
Thanks!
Titanium abstracts those events for you - so you don't have to worry about writing them for iOS/Android each.
Check out the Titanium.App documentation (http://docs.appcelerator.com/platform/latest/#!/api/Titanium.App). You can see what events are available at the app level (of course, each Titanium components has it's own events - but those are at app level).
If I understand your question, the relevant events for you are paused and resumed - when the app goes in the background and then back to foreground.
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
WP7: Is it possible to intercept the backstack before the journal thumbnail is created/stored
I have an app with personal data that should not be displayed in the task viewer of WP8 when the app is send to background.
My idea was to raise a black page in the Application_Deactivated event, but the UI only seems to update when the app is reactivated again, in the task viewer is still the old UI.
Do you have any ideas/solutions for this problem?
This is not possible. There is no lifecycle event that you can 'hook into' before your application 'screenshot' is obtained for the fast-app switching UI. You are going to have to re-think your application.
However, +1 for actually coming up with a reasonable scenario for wanting to achieve this
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Windows Phone 7 close application
I have an app which needs quiting from the MainPage but just using NavigationService.GoBack() won't work when another screen has navigated to that main page as I don't want the ability to go back to that previous page.
Would I have to set a variable in App.xaml.cs called backToBeginning and all the onnavigatedto callbacks will GoBack() if that is set? or is that too messy?
WP7 does not support exiting of apps. Just let the user do it with the back button.
Currently, there is no way to achieve this. What you have described is really needed in the Music+Video hub, but due to inability to to it with the way navigation in WP7 is organized, even Microsoft had to sacrifice the functionality of a very important build-in application.