InterviewSolution
| 1. |
I have two activities: main activity as Activity A and child activity as Activity B. When I press a button Next in the ActivityA, it will call the ActivityB. Suppose I have to send data back to Activity A from Activity. How I will do that? |
|
Answer» In Android, service is a component which is like ACTIVITY and running in the background. Once it is started, it will run in the background even if the application goes background. But from Android O, they INTRODUCE a new concept that a user should know what TASK is running in the background and it also should show the notification to user with some action buttons so that the user can INTERACT with the ongoing operation if they want. So for this, we have the best approach called as an Android Foreground Service. This foreground service is giving notification to the user that task is running in the background, for example, playing music or downloading files from the internet. And if the user wants to stop that service, then he can stop using Notification. So to create foreground service you have to use NotificationManager.startServiceInForeground() method to send a notification to the user that the Background Service is running and if he wants he can stop it. |
|