如何在服务中敬酒?
How to show toast in service?
我是 android 的新人。我在敬酒时遇到了问题。
val configBuilder = FirebaseRemoteConfigSettings.Builder()
if (BuildConfig.DEBUG) {
val cacheInterval: Long = 0
configBuilder.setMinimumFetchIntervalInSeconds(cacheInterval)
}
使用这样的代码,
public class MyService extends Service {
String msg="Toast message show";
Thread t = new Thread(){
public void run(){
Message myMessage=new Message();
Bundle resBundle = new Bundle();
resBundle.putString("status", "SUCCESS");
myMessage.obj=resBundle;
handler.sendMessage(myMessage);
}
};
}
private Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
Toast.makeText(getApplicationContext(), "msg", Toast.LENGTH_LONG).show();
}
}
我是 android 的新人。我在敬酒时遇到了问题。
val configBuilder = FirebaseRemoteConfigSettings.Builder()
if (BuildConfig.DEBUG) {
val cacheInterval: Long = 0
configBuilder.setMinimumFetchIntervalInSeconds(cacheInterval)
}
使用这样的代码,
public class MyService extends Service {
String msg="Toast message show";
Thread t = new Thread(){
public void run(){
Message myMessage=new Message();
Bundle resBundle = new Bundle();
resBundle.putString("status", "SUCCESS");
myMessage.obj=resBundle;
handler.sendMessage(myMessage);
}
};
}
private Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
Toast.makeText(getApplicationContext(), "msg", Toast.LENGTH_LONG).show();
}
}