In service , the effect of this dialog is no problem .
But if it is in intentservice , the same as the start dialog code, all run , no error, just do not show this dialog box , which is why?
Great God seeking answers ah ! ! ! !
intentservice is a subclass of service , which in addition to the message handling both bit different, why this difference so big? ? ? ? Jia ! ! !
intentservice in the part of the code :
protected void onHandleIntent (Intent intent) {
_DownloadApkService.requestService ();
}
then requestService () in a dialog box will open to display the dialog code as follows:
public void showUpdateDialog(){
View v = View.inflate(context, R.layout.update, null);
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle("yyyyyyyy");
String new_version_desc = getSharePreferences(HybridGlobalDefination._New_Version_Desc, "New Version, download now?");
builder.setMessage(new_version_desc);
builder.setView(v);
tDialog = builder.create();
tDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
tDialog.show();
WindowManager.LayoutParams lp = tDialog.getWindow().getAttributes();
WindowManager wm = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
if(display.getHeight() > display.getWidth()){
lp.width = (int)(display.getWidth() * 1.0);
}
else{
lp.width = (int)(display.getWidth() * 0.5);
}
tDialog.getWindow().setAttributes(lp);
Button bt1 = (Button)tDialog.getWindow().findViewById(R.id.button2);
bt1.setOnClickListener(new Button.OnClickListener(){
public void onClick(View v) {
downloadStatusBar();
tDialog.dismiss();
}
});
Button bt2 = (Button)tDialog.getWindow().findViewById(R.id.button1);
bt2.setOnClickListener(new Button.OnClickListener(){
public void onClick(View v){
tDialog.dismiss();
}
});
}
Jiqiu reason ah ! !
I really tried, as long as it is not the problem into Service replaced IntentService will not show up . . I am not too much points . Thanks! ! !
------ Solution ---------------------------------------- ----
Intentservice
child thread can not operate the UI thread.
------ Solution ---------------------------------------- ----
send it to the activity to start broadcasting it
------ eference ------------------ dialog ---------------------
I also found this problem that I wanted to display a dialog box with INTENTSERVICE how do I
- ----- eference ---------------------------------------
ah . I was so used currently . But would like to replace that method I asked . Not like I do not change it. Changed so that it would listen to the radio activity .
------ eference --------------------------------------- < br> intentservice after the completion of the implementation of the method will automatically call stopself so can not be used to end his
没有评论:
发表评论