我想通过意图服务来更新对话框中的消息。我已经将这样的意图服务称为:
Boolean checkNetworkBeforeSync = NetworkHelper.hasNetworkAccess(this);
if (checkNetworkBeforeSync){
MaterialDialog dialogSync = new MaterialDialog.Builder(EnterDataView.this)
.title("Please Wait")
.content("Uploading Data...")
.progress(true, 0)
.cancelable(false)
.show();
Intent serviceIntent = new Intent(this, UploadService.class);
startService(serviceIntent);
}else{
Toast.makeText(this, "Sync failed: You're not connected to the internet.", Toast.LENGTH_LONG).show();
}
意图服务将SQLite数据上载到服务器。我具有要在意图服务中上载的确切数据数量,但是我想向用户更新有关已上载多少数据的信息。当上传任务完成时,我正在使用广播接收器关闭对话框:
private BroadcastReceiver uBroadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String checkSyncStatus = intent.getStringExtra("CheckUploadStatus");
if(checkSyncStatus.equals("true")){
dialogSync.dismiss();
}
}
};
我的问题是如何将对话框中的消息更新为“上载2000个数据中的100个”?