Xamarin.Android - Keep the app working in background after closing it with a local notification












0














Currently, I have a mobile application written in Xamarin.Android. Because there are constant HTTP requests going on in the app, what I'd like to do is keep the application active after closing it.



What I am looking at, is for example after you close the app, in the background it keeps sending HTTP requests, but there is a local notification where when you click it you can open the app. There should be an explicit button for the exit which could be inside the application. In more details, HTTP requests are sent on some interval in seconds.



So my end goal is to have the app constantly running, if it's in a background, then show a notification that it's still up and be able to close it (even from the background) only from the inside of the app.



I couldn't find many resources specifically about this question and I am not quite sure what I can use in order to make this work.



Thanks in advance!










share|improve this question






















  • You should review the various Service classes available to Android and the latest WorkManager: developer.android.com/topic/libraries/architecture/workmanager FYI: A user always has the ability to terminate and "Force Quit" an app
    – SushiHangover
    yesterday










  • @SushiHangover I've noticed that in newer versions of Android (6 and up) that a background service is no longer listed in Apps if it is running within its own process.
    – sam.is
    yesterday


















0














Currently, I have a mobile application written in Xamarin.Android. Because there are constant HTTP requests going on in the app, what I'd like to do is keep the application active after closing it.



What I am looking at, is for example after you close the app, in the background it keeps sending HTTP requests, but there is a local notification where when you click it you can open the app. There should be an explicit button for the exit which could be inside the application. In more details, HTTP requests are sent on some interval in seconds.



So my end goal is to have the app constantly running, if it's in a background, then show a notification that it's still up and be able to close it (even from the background) only from the inside of the app.



I couldn't find many resources specifically about this question and I am not quite sure what I can use in order to make this work.



Thanks in advance!










share|improve this question






















  • You should review the various Service classes available to Android and the latest WorkManager: developer.android.com/topic/libraries/architecture/workmanager FYI: A user always has the ability to terminate and "Force Quit" an app
    – SushiHangover
    yesterday










  • @SushiHangover I've noticed that in newer versions of Android (6 and up) that a background service is no longer listed in Apps if it is running within its own process.
    – sam.is
    yesterday
















0












0








0







Currently, I have a mobile application written in Xamarin.Android. Because there are constant HTTP requests going on in the app, what I'd like to do is keep the application active after closing it.



What I am looking at, is for example after you close the app, in the background it keeps sending HTTP requests, but there is a local notification where when you click it you can open the app. There should be an explicit button for the exit which could be inside the application. In more details, HTTP requests are sent on some interval in seconds.



So my end goal is to have the app constantly running, if it's in a background, then show a notification that it's still up and be able to close it (even from the background) only from the inside of the app.



I couldn't find many resources specifically about this question and I am not quite sure what I can use in order to make this work.



Thanks in advance!










share|improve this question













Currently, I have a mobile application written in Xamarin.Android. Because there are constant HTTP requests going on in the app, what I'd like to do is keep the application active after closing it.



What I am looking at, is for example after you close the app, in the background it keeps sending HTTP requests, but there is a local notification where when you click it you can open the app. There should be an explicit button for the exit which could be inside the application. In more details, HTTP requests are sent on some interval in seconds.



So my end goal is to have the app constantly running, if it's in a background, then show a notification that it's still up and be able to close it (even from the background) only from the inside of the app.



I couldn't find many resources specifically about this question and I am not quite sure what I can use in order to make this work.



Thanks in advance!







android xamarin xamarin.android android-notifications android-background






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked yesterday









Shiva

32




32












  • You should review the various Service classes available to Android and the latest WorkManager: developer.android.com/topic/libraries/architecture/workmanager FYI: A user always has the ability to terminate and "Force Quit" an app
    – SushiHangover
    yesterday










  • @SushiHangover I've noticed that in newer versions of Android (6 and up) that a background service is no longer listed in Apps if it is running within its own process.
    – sam.is
    yesterday




















  • You should review the various Service classes available to Android and the latest WorkManager: developer.android.com/topic/libraries/architecture/workmanager FYI: A user always has the ability to terminate and "Force Quit" an app
    – SushiHangover
    yesterday










  • @SushiHangover I've noticed that in newer versions of Android (6 and up) that a background service is no longer listed in Apps if it is running within its own process.
    – sam.is
    yesterday


















You should review the various Service classes available to Android and the latest WorkManager: developer.android.com/topic/libraries/architecture/workmanager FYI: A user always has the ability to terminate and "Force Quit" an app
– SushiHangover
yesterday




You should review the various Service classes available to Android and the latest WorkManager: developer.android.com/topic/libraries/architecture/workmanager FYI: A user always has the ability to terminate and "Force Quit" an app
– SushiHangover
yesterday












@SushiHangover I've noticed that in newer versions of Android (6 and up) that a background service is no longer listed in Apps if it is running within its own process.
– sam.is
yesterday






@SushiHangover I've noticed that in newer versions of Android (6 and up) that a background service is no longer listed in Apps if it is running within its own process.
– sam.is
yesterday














1 Answer
1






active

oldest

votes


















0














According to the documentation what you're trying to do is supported:




Sending notifications to the user



When a service is running, it can notify the user of events using
Toast Notifications or Status Bar Notifications.



A toast notification is a message that appears on the surface of the
current window for only a moment before disappearing. A status bar
notification provides an icon in the status bar with a message, which
the user can select in order to take an action (such as start an
activity).



Usually, a status bar notification is the best technique to use when
background work such as a file download has completed, and the user
can now act on it. When the user selects the notification from the
expanded view, the notification can start an activity (such as to
display the downloaded file).



See the Toast Notifications or Status Bar Notifications developer
guides for more information.




ref: https://developer.android.com/guide/components/services

ref: https://developer.android.com/guide/components/processes-and-threads






share|improve this answer





















  • Hi, thank you for your answer, it's very helpful. Yet, one of the problems I got is that the user can terminate the app at any time from Android apps-switch. So I an not quite sure if I can handle this behavior. What I mean is, whenever the user is terminating the app, then to handle this event, add anything to the status bar and keep the app working in the background. If he wants to close it, then to do that explicitly from the application. The goal is to keep the app always open when the phone is turned on as it's sending some statistics for the device.
    – Shiva
    yesterday













Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53944793%2fxamarin-android-keep-the-app-working-in-background-after-closing-it-with-a-loc%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














According to the documentation what you're trying to do is supported:




Sending notifications to the user



When a service is running, it can notify the user of events using
Toast Notifications or Status Bar Notifications.



A toast notification is a message that appears on the surface of the
current window for only a moment before disappearing. A status bar
notification provides an icon in the status bar with a message, which
the user can select in order to take an action (such as start an
activity).



Usually, a status bar notification is the best technique to use when
background work such as a file download has completed, and the user
can now act on it. When the user selects the notification from the
expanded view, the notification can start an activity (such as to
display the downloaded file).



See the Toast Notifications or Status Bar Notifications developer
guides for more information.




ref: https://developer.android.com/guide/components/services

ref: https://developer.android.com/guide/components/processes-and-threads






share|improve this answer





















  • Hi, thank you for your answer, it's very helpful. Yet, one of the problems I got is that the user can terminate the app at any time from Android apps-switch. So I an not quite sure if I can handle this behavior. What I mean is, whenever the user is terminating the app, then to handle this event, add anything to the status bar and keep the app working in the background. If he wants to close it, then to do that explicitly from the application. The goal is to keep the app always open when the phone is turned on as it's sending some statistics for the device.
    – Shiva
    yesterday


















0














According to the documentation what you're trying to do is supported:




Sending notifications to the user



When a service is running, it can notify the user of events using
Toast Notifications or Status Bar Notifications.



A toast notification is a message that appears on the surface of the
current window for only a moment before disappearing. A status bar
notification provides an icon in the status bar with a message, which
the user can select in order to take an action (such as start an
activity).



Usually, a status bar notification is the best technique to use when
background work such as a file download has completed, and the user
can now act on it. When the user selects the notification from the
expanded view, the notification can start an activity (such as to
display the downloaded file).



See the Toast Notifications or Status Bar Notifications developer
guides for more information.




ref: https://developer.android.com/guide/components/services

ref: https://developer.android.com/guide/components/processes-and-threads






share|improve this answer





















  • Hi, thank you for your answer, it's very helpful. Yet, one of the problems I got is that the user can terminate the app at any time from Android apps-switch. So I an not quite sure if I can handle this behavior. What I mean is, whenever the user is terminating the app, then to handle this event, add anything to the status bar and keep the app working in the background. If he wants to close it, then to do that explicitly from the application. The goal is to keep the app always open when the phone is turned on as it's sending some statistics for the device.
    – Shiva
    yesterday
















0












0








0






According to the documentation what you're trying to do is supported:




Sending notifications to the user



When a service is running, it can notify the user of events using
Toast Notifications or Status Bar Notifications.



A toast notification is a message that appears on the surface of the
current window for only a moment before disappearing. A status bar
notification provides an icon in the status bar with a message, which
the user can select in order to take an action (such as start an
activity).



Usually, a status bar notification is the best technique to use when
background work such as a file download has completed, and the user
can now act on it. When the user selects the notification from the
expanded view, the notification can start an activity (such as to
display the downloaded file).



See the Toast Notifications or Status Bar Notifications developer
guides for more information.




ref: https://developer.android.com/guide/components/services

ref: https://developer.android.com/guide/components/processes-and-threads






share|improve this answer












According to the documentation what you're trying to do is supported:




Sending notifications to the user



When a service is running, it can notify the user of events using
Toast Notifications or Status Bar Notifications.



A toast notification is a message that appears on the surface of the
current window for only a moment before disappearing. A status bar
notification provides an icon in the status bar with a message, which
the user can select in order to take an action (such as start an
activity).



Usually, a status bar notification is the best technique to use when
background work such as a file download has completed, and the user
can now act on it. When the user selects the notification from the
expanded view, the notification can start an activity (such as to
display the downloaded file).



See the Toast Notifications or Status Bar Notifications developer
guides for more information.




ref: https://developer.android.com/guide/components/services

ref: https://developer.android.com/guide/components/processes-and-threads







share|improve this answer












share|improve this answer



share|improve this answer










answered yesterday









sam.is

3,40362151




3,40362151












  • Hi, thank you for your answer, it's very helpful. Yet, one of the problems I got is that the user can terminate the app at any time from Android apps-switch. So I an not quite sure if I can handle this behavior. What I mean is, whenever the user is terminating the app, then to handle this event, add anything to the status bar and keep the app working in the background. If he wants to close it, then to do that explicitly from the application. The goal is to keep the app always open when the phone is turned on as it's sending some statistics for the device.
    – Shiva
    yesterday




















  • Hi, thank you for your answer, it's very helpful. Yet, one of the problems I got is that the user can terminate the app at any time from Android apps-switch. So I an not quite sure if I can handle this behavior. What I mean is, whenever the user is terminating the app, then to handle this event, add anything to the status bar and keep the app working in the background. If he wants to close it, then to do that explicitly from the application. The goal is to keep the app always open when the phone is turned on as it's sending some statistics for the device.
    – Shiva
    yesterday


















Hi, thank you for your answer, it's very helpful. Yet, one of the problems I got is that the user can terminate the app at any time from Android apps-switch. So I an not quite sure if I can handle this behavior. What I mean is, whenever the user is terminating the app, then to handle this event, add anything to the status bar and keep the app working in the background. If he wants to close it, then to do that explicitly from the application. The goal is to keep the app always open when the phone is turned on as it's sending some statistics for the device.
– Shiva
yesterday






Hi, thank you for your answer, it's very helpful. Yet, one of the problems I got is that the user can terminate the app at any time from Android apps-switch. So I an not quite sure if I can handle this behavior. What I mean is, whenever the user is terminating the app, then to handle this event, add anything to the status bar and keep the app working in the background. If he wants to close it, then to do that explicitly from the application. The goal is to keep the app always open when the phone is turned on as it's sending some statistics for the device.
– Shiva
yesterday




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53944793%2fxamarin-android-keep-the-app-working-in-background-after-closing-it-with-a-loc%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Monofisismo

Angular Downloading a file using contenturl with Basic Authentication

Olmecas