dckrOff / Background-And-Foreground-Service-Example

Understanding and Using Services in Android: Background & Foreground Services
https://medium.com/@Codeible/understanding-and-using-services-in-android-background-foreground-services-8130f6bbf2a5
3 stars 1 forks source link

Foreground Service in Android 13/SDK 33 #1

Open patelakshay13890 opened 1 year ago

patelakshay13890 commented 1 year ago

How Can I Create Foreground Service in Android 13/SDK 33? In my sample I want to Read SMS that received has some Specific Word than I have to sync to Server by Network Calls. So How can I do this sir ? And When Internet Not Available while Receiving SMS than how Can I have Internet Connection Receiver in Service itself to check Connection and when Connection is available than Sync SMS to Server those are pending.. And I want to Auto Start this App/Service when Device is Reboot.. Please Help me out.. Thanks..

dckrOff commented 1 year ago

@patelakshay13890 You can do this in several ways, for example using fcm (FirebaseCloudMessaging) or on your server you can use a socket (web socket, socket.io, etc). if you need to check messages from the server at a fixed time (for example, every day at 8 a.m.) without a socket, use an alarmManager and create a Notification.Builder in the BroadcastReceiver class. When it comes time to check messages from the server in this class, check if the device is connected to the Internet, if connected, you can send a request to the server.

Sources that can help: Android Developer | GeeksForGeeks | Medium | StackoverFlow En | StackoverFlow Ru

if you have any other questions, please contact