How to show a dialog without context in kotlin - android

I want to show a dialog to the user saying "Session expired please login again". But the problem is when I am making the network call the user might have changed the screen and the context which I passed is no longer useful to show the dialog. By changing the screen I don't mean that user changed the application they are still on the same application.
I am using one activity and on top of that there are many fragments.

Related

Understanding how work with flexible in-app updates

I'm trying to implement in-app updates in my application but I'm facing a doubt about how to work with flexible updates. I will show the flexible update to the user in the splash screen when the user open the application, what I need to do before this? Can the user navigate on the application or I need to force the user to keeps on the splash screen until the update are done?
My doubt about this it's because of the snackbar that I want to show to her when the update are done, notifying the user to restart the app, but if I initiate the in-app update listener in the splash and let the user continue the navigation, how can I show the snackbar?
I'm trying to implement in-app updates in my application but I'm facing a doubt about how to work with flexible updates. I will show the flexible update to the user in the splash screen when the user open the application, what I need to do before this?
Your question is unclear. Your user opens the app, you present the option to update in the background. OK. So ... what else needs to happen "before this"?
Can the user navigate on the application or I need to force the user to keeps on the splash screen until the update are done?
Allowing the user to navigate the application is exactly the purpose of doing a flexible update.
My doubt about this it's because of the snackbar that I want to show to her when the update are done, notifying the user to restart the app, but if I initiate the in-app update listener in the splash and let the user continue the navigation, how can I show the snackbar?
Have you read the documentation that explains exactly how to do this?

Show dialog from service

I'm creating a voip app and when a call comes in I need to alert the user so they can accept or reject the call. I want a dialog like what hangouts uses:
I've tried using an alert dialog with type TYPE_SYSTEM_ALERT. However there are issues with this:
It requires ugly system permissions. (takes you to a full screen activity to accept overlay permissions)
It displays centered vertically not at the top over the top bar.
Any time anyone asks about this online everyone says your shouldn't be doing it this way, but doesn't tell you how to actually do it.
I didn't have to accept any overlay system permissions on my hangouts so how does google do it?
What is the correct way to display a dialog to the user from a service to accept a call?

Bypassing dialog bug in Android

I have an application which in certain areas, a dialog pops up and restricts the user from proceeding. There are currently two types of dialogs. One restricts the user entirely from proceeding and the other allows the user to proceed if they click on "OK".
The problem:
When the dialog appears, if I close the application and relaunch it, the app bypasses the dialog and gains access to the next screen. On one of the cases, the app bypasses the screen and shows that screen which the user was previously on before the dialog appeared.
Does anyone have an idea what may be the problem?

android ui - how to implement a series of dialogs

I have the following flow in my application and dont know how to implement this in an android way.
The user can check in the app if there is a update available, if so he can choose if he wants to download it, and once it is downloaded an update of the database takes place.
In the android documentation I only find basic description of either a progress dialog, or alert dialog but not how to have something more complex. For the sake of the example what i would like is the following.
The user clicks the check for update button
A progress dialog with checking for update pops up (which can be canceled)
If there is no update available the user gets informed and can click ok.
If there is an update available the user can choose to download it or cancel.
If he chooses to download he sees a progress bar. (with a cancel button)
Once the download is finished he sees a database updating alert dialog.
Finally he gets an all is done info and can click ok
Just an example yet what is the android way of implementing a series of dialogs like this. Wizard, series of different dialogs, one always changing one ...
Suggestion how to implement this in a recommended way would be highly appreciated
thanks
martin
Each dialog can launch the next subsequent dialog and automatically dismiss itself. Look at the DialogListeners attached to each button in example code

Android: Determine the previously displayed external Activity

In my application, I used a library that displays ads in my app. When a user clicks on the ad, it launches the Browser app, and the onClick events are handled by the library itself.
I also have a placed code in onPause() and onStart() methods that detects whether any of my Activities are sent to background (user pressed Home) or switching between any of my Activities.
So if the app is either freshly opened (no instance is running) or re-opened from background, it will display a dialog box. If the user is only switching from any of my Activites, then the dialog box shouldn't be displayed.
Now the problem is that when the user clicks on an Ad, the Browser app gets loaded and would mean that my App has been sent to background, and so when the user closes the Browser, it will still display the dialog box when it shouldn't.
Is it even possible for my App to determine the previously displayed external Activity (ie. Browser) and not display the dialog box?
Or are there better approaches that I can follow in implementing such setup?
Thanks in advance.
I don't think that there is a way for your Activity to know, which was the previous activity. A simple work-around is to save the time the dialog was displayed and not displayed it again, before some time passes. You can decide on the exact time period based on your application's requirements.
This may be in fact better in some situations. If the user switches from the Browser to your application and it has been some time he has used your application, it will be appropriate to show the dialog again.
you can use onResume() method to specify the behaviour when your activity get back from the background.

Categories

Resources