How to call an Activity's non-static method from inside a service onStart()?
You can call startService(intent) and bindService(mIntent, mConnection, BIND_AUTO_CREATE) in any order. Binding and Starting a service are two independent things.
Intent intent = new Intent(myActivity. this, myActivity. class); PendingIntent contentIntent = PendingIntent. getActivity(this, REQUEST_CODE, intent, 0); notification.
Services are a unique component in Android that allows an application to run in the background to execute long-running operation activities, on the other hand, an activity, like a window or a frame in Java, represents a single screen with a user interface.
How to call an Activity's non-static method from inside a service onStart()?
You can't.
However, there are many ways to have a service communicate with a running activity, and I outline some of them here: How can I update information in an Android Activity from a background Service
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With