Comments (1)
Need more information about your service. If possible can you share your code?
Toast always works with Application's main thread. So you have to be sure that you use thread in main thread.
And still if you want to use Toast in service, then you have to use Handler.
Please check out the below example for Handler in Thread :
private Context mContext;
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
mContext=getApplicationContext();//Get the context here
}
//Use this method to show motion toast
void showToast(){
if(mContext != null){
Handler handler = new Handler(Looper.getMainLooper());
handler.post(new Runnable() {
@Override
public void run()
{
// Motion toast here
}
});
}}`
from motiontoast.
Related Issues (20)
- Toast not working in a service
- RTL support
- Background Color Changing Problem
- While setting the Gravity to Top it automatically gets attached to left side of the screen HOT 2
- (BUG) Toast not working in a service
- Some functions are not available in Java
- motion toast make fab button black
- motion toast make fab button black
- Java Implementation Examples HOT 2
- Android Studio is unable to find the repo HOT 1
- NEED SOLUTION - Fatal Exception: java.lang.NullPointerException
- Duration not working HOT 2
- Migrate to View Binding
- When we call the MotionToast libary from Fragment It will show he Error
- setGravity
- Toast#setView Deprecated in API 30
- Long description text not showing completely HOT 1
- Landscape is not centered horizontally
- Readme file contains some compile time error
- Fragment issue HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from motiontoast.