版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_24675479/article/details/80394200
刚开始想了很多,service与activity通信,service获取activity的布局和id控制显示,最后解决办法
service
UIUtils.showLoading();//直接调用外部方法
public class UIUtils {
public static BaseActivity currentAct;
private static AlertDialog mDialog;
public static void showLoading() {
//添加布局
mDialog = new AlertDialog.Builder(currentAct, R.style.dialog1).setContentView(R.layout.loading_view)
.setWidthAndHeight(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)
.show();
}
}
BaseActivity的onResume
@Override
protected void onResume(){
super.onResume();
UIUtils.currentAct = this;
}