Activity description :
The main idea is to have an sms sending list and when user clicks the 'Send' button, the broadcast receivers start to receive and GUI changes like highlighting the 'Sent/Not sent' member list, updating progress bar , counting etc
Problems : Activity runs for hours and it's very important to save the exact same GUI change in sync with the user's action on the phone
However I have a few problems and th
The battery is dead/app crash.
Solution : Saving each 'send' state to file and loading it the next time when the user runs the app
The user hits the back/stop button or has an incoming call / Just wants to surf the web.
Solution : Maybe keep running it in the background? by using transparent activity ?
*NOTE : its not about the 'save' state or 'restore' state because everything depends on the broadcast receiver
Ideal way could be
do the backend logic with broadcast recievers + intent service and log the data in backend
Use the activity to just display the UI state based on the saved data.
Related
on one screen in my application, I am recording audio.
Scenario: User records audio on this screen. A push comes from our application. The user clicks on this push and another push processing activity is launched.
Result: The user loses his session.
Question: what are the options for handling this case so that the user does not lose his session? Ideally, before switching to a new activity, the application would ask the user if he is sure that he wants to go to another screen, because the session will be lost. But how to track it?
Thanks a lot for your advice
The best solution I have found is to clear all old push notifications in the notification shade when going to the recording screen.
val notificationsManager = getSystemService<Any>(Context.NOTIFICATION_SERVICE) as NotificationManager?
notificationsManager!!.cancelAll()
Further during the recording, if a push notification arrives, I receive this in my service inherited from FirebaseMessagingService in onMessageReceived().
If the recording screen is currently open, I do not show a notification in the notification shade. But I show a widget on the recording screen with the push text and if the user presses it I ask if the user wants to go to another screen because the recording will end.
I hope my experience helps someone. Similarly implemented in Intercom
I want to make a task which,
functions as a count-down timer
*which work on activity (show the count-down in the text field )
*and background at the same time.
*Then background service shows a notification after the count-down finished,
*not just that if the app is closed and reopen, I want to show up the remaining time in the text field
what should I do, to achieve these four jobs
Try to open a service on foreground method (background service cannot act well nowadays), it is up to you.
Your task counting info will save in (foreground) service
So when your app will reopen, your MainActivity will collect data from your service and display it in own TextBox.
For collecting data from service you can use BroadcastReceiver which starts within service.
You can show a notification from your service, it will be better if time count is end before app reopen.
You also can show notification from your activity if you ensure that user have to return your app before count down end.
I have not enough reputation for comment thats why i replied for answer.
I have created a music player app, where when a user plays a song, a services is started and a notification with media control is displayed to the user.
I am facing issues when the user clicks on next or previous button in the notification panel.
When the user clicks on next button, the song changes and starts playing.
The problem i am facing is that, when the song is changed, the Notification UI is updated with the new song information, but my App's player screen is not updating the new song info.
I tried to debug, the data is proper, like the new song info which is being passed to TextView.setText() is correct, also when i immediately print TextView.getText() in the logs, its showing current info, but the UI is displaying old info and not reflecting this new info. The same is happening with other UI elements.
I am using a Manifest declared broadcast to receive Player control actions from the Notification.
When the broadcast receives the message to play next song, it calls the function to change the song, the song changes, the UI data is coming proper, the Textview is receiving it and getText() also returns the new data but the UI is not updating.
Can anyone help me here ? Thanks in advance.
I have an Splash Screen activity that launches an Asynctask that goes off and downloads and processess alot of data. It takes a while (20ish seconds) and it's a refresh of data so I dont wait for it and so send my users to a main activity where they can view the last cached data (with an indicator data is still downloading).
What is the best way (or any way) for the async task to notify the main activity (or any other current activity the user is viewing) that its done and to refresh screen and stop the indicator?
FYI, I dont want to just launch the AsyncTask from the Main as there are 3 other activitys that the user may have navigated to that all would need to know when it is done and to stop showing the indicator.
Your AsyncTask can broadcast an Intent when the data is available. The current Activity can set up a listener for that broadcast Intent and refresh the screen when it get it.
I have a little problem with an alert View, the idea is that when the app starts, it asks on background for new data for the app, so after receiving the information an AlertView should be shown if there is new data. The problem comes because the AlertView is only shown on the main activity where I launched the asyncTask, so if I'm already in other activity, the alert will appear when I come back to the main activity and the Idea is that the AlertView is displayed in whatever activity the user is in.
My first thought was that the Context that I send to the AsyncTask is the problem so I've tried using getApplicationContext() so the app crashes in the moment of creating the alertView. So I'm, looking for a way to display this AlertView or something equivalent on the screen wherever he is on the app, does any one have ideas?
any idea would be greatly appreciated
you can use broadcastreceiver in every activity which will contineous monitor your background service contineous whenever event occoured using broadcastreceiver display alertbox with content received by receiver.