This is how I did it. Of course, you need to pass appropriate context.
Handler h = new Handler(context.getMainLooper());
h.post(new Runnable() {
@Override
public void run() {
Toast.makeText(context,message,Toast.LENGTH_LONG).show();
}
});
More Related Contents:
- Service Ended When I Kill App
- Trying to start a service on boot on Android
- Android – implementing startForeground for a service?
- Android – Listen For Incoming SMS Messages
- Android background music service
- Service vs IntentService in the Android platform
- Recommended way / order to read data from a webservice, parse that data and insert it in a SQLite db
- START_STICKY does not work on Android KitKat
- Creating an Android Service with Phonegap? (Have phonegap app run even when closed)
- BroadcastReceiver when wifi or 3g network state changed
- Continue Service even if application is cleared from Recent app
- Get Context in a Service
- How to always run a service in the background?
- Android RuntimeException: Unable to instantiate the service
- How to run an android app in background?
- Permission Denial: startForeground requires android.permission.FOREGROUND_SERVICE
- Android L (API 21) – java.lang.IllegalArgumentException: Service Intent must be explicit
- What is the difference between an IntentService and a Service? [duplicate]
- Download multiple files with a progress bar in ListView Android
- How to run CountDownTimer in a Service in Android?
- Debugging a service
- Control the default music player of android or any other music player
- How does doze mode affect background/foreground services, with/without partial/full wakelocks?
- Reasons that the passed Intent would be NULL in onStartCommand
- Samsung “App optimisation” feature kills background applications after 3 days
- SpeechRecognizer causes ANR… I need help with Android speech API
- Bad notification posted – Couldn’t expand RemoteViews for: StatusBarNotification
- Android O – Detect connectivity change in background
- Register GCM from a library project
- Android application as a service without activity