Context:
I have a Xamarin app (using Xamarin.Forms)
Issue is with Android version only.
There is a reset password form.
That form sends a request to a server, which issues an SMS with a code.
The app automatically displays the verification code form, by pushing a new view on the stack.
The user then checks code in the SMS app, switchesback to my app, and enters the code.
Problem:
Some times the flow above works fine.
Other times, when the user switches back to my app from the SMS, the app reverts back to the root navigation page.
Notes:
I am having trouble identifying the root cause. I suspect that it is due to page activity lifecycle, and that in the scenarios when it doesn't work, the OS has deallocated resources from my app, thus reloads it.
Please see diagram attached.
Questions:
Is anybody able to suggest a way to debug this so I know for sure
what is the root cause?
Is anybody able to suggest a way to handle app switching in Xamarin
Android so that state is maintained?
Related
I've been asked to fix an android application which has issues after switching to a newer device. The switch was from android 7/8 to 11. The application opens up google maps for navigation but very often when returned to the app all data is lost, and clicking on anything will reset it back to the startup activity. It doesn't matter which apps it switches between the issue happens with all of them.
I've tried several things:
-Disabling all battery saving options on the device
-Using OnSaveInstanceState to retain the data
-Using a backgroundservice to retain the data
The issue only occurs on actual devices, using an emulator results in no errors.
When the debugger is attached to the application it loses its connection before returning to the app. It is possible to re-attach when returning to the app but it disconnects as soon as
anything is clicked.
And best of all there's literally no error message shown anywhere.
The following comment provided the solution I needed.
You would need to start a foreground service, complete with its Notification. Even that does not guarantee that your process will remain around.
– CommonsWare Sep 1 at 12:40
I have an android app which is a wrapper around my mobile site. We have a site that changes everyday, and I’d like to have a method by which I can notify the user that there’s new content to be had, or just reload it programmatically.
This obviously happens when the app relaunches, but sometimes users will keep the app in sleep mode and re-open it the next day and they see a stale version of the website. Is there any way around without going native? One method I thought off was using a push notification to reload the app (i.e. use GCM to tell the app to reload the page) except I don’t want to push a new version as this would require permission changes and that would break auto-updating. I though of using socket.io for the task as I'm already using it in my app but I don’t think it'll work if the app is the background (will it? I’m an android newbie)
Thanks for any help!
When the application returns from sleep - onResume() of the activity life cycle may be invoked. If you reload the webview on this listener, that should resolve it.
Unless i am missing something very significant, this simple solution might work.
I'm currently building an application for Android using NFC-technology. The NFC-part is being used to log in to the app. So here's the deal: i want the app to respond differently when detecting the tag when it is already running. Here are the two situations:
1) When the user scans a tag with a specific URI, the app launches, loading the URI into the username-textfield. User then enters his password, presses login, and voila, magic. This part works fine.
2) Now, i also want the app to be launched from the app-list, showing a login form. No problem, i use a different activity for that. But now, how do i make some sort of custom Event Listener that makes the app wait for the tag to be scanned, and then puts the URI into the username-field without, and here it comes, launching the app again, as described in situation 1?
Hope you guys can help me out here, sorry for the long text.
Use foreground mode for your open activity and it will be able to receieve all NDEF messages (from tag or beam). Check boilerplate project in this project (shameless plug).
Your application itself simply needs to be aware of it's own current state and respond to the scanned tag accordingly
I have developed one app in which there is option for sharing on twitter.Its working properly fine.Now one requirement came which says that if the app is force killed it should again ask for authentication with twitter so that we can give user id and password again.The main thing is if user want to login to twitter with his new credentials how he will do that.Any idea how to solve this issue.Right now if i am uninstalling the app or clearing the data it is doing authentication but it should do on force killing the app.
You can't detect your app being force killed: https://groups.google.com/forum/?fromgroups#!topic/android-developers/xfkfRc-j4cw
It might be possible to set a flag when your app starts, and clear the flag when your app stops in an orderly way. If the flag is set when your app is starting, then you know it was last stopped in a disorderly way, like being force killed. This method of detection will probably give you both false positives (if someone pulls the battery out of their phone, your flag will probably still be set) and false negatives (if your app considers itself to have been stopped in an orderly way, and is then force killed). This method will surely give you angst and tears unto the fifth generation. Here be dragons, and the dragons will eat you.
You should push back against the requirement.
For your problem, you can clear your tokens when the app starts again, in an onStart(); method for example. So next time the user will use the application after the forced kill, this last wouldn't get any access tokens to work properly and would be consequently "forced" to ask tokens again via a classic OAuth Authentication Flow.
Reauthentications are just like classic authentications. At the end, the Twitter API will give you back the missed (or deleted) access tokens.
I've created a simply web radio streaming app, and on of my app user told me that sometimes when he open another app (for example, Facebook app) my app gets close without error.
How can I trace this event?
Thank you!
It sounds like your app is simply experiencing the standard Activity lifecycle.
When the user leaves your app (eg opens the Facebook app), onStop() is called. From there, the app can either be restarted, it can just sit there, or it can be destroyed.
Since the Facebook app is fairly resource-intensive, I am guessing that the system is destroying your app to free up resources for the Facebook app, or whatever other app is being launched.
If you tell us more about what you are trying to accomplish, we can provide more suggestions on how to do that.