intentservice启对话框,显示不出来??
将一个xml layout以对话框的形式显示出来
在service里,起这个对话框是完全没有问题的。
但是如果是在intentservice里,一样的启对话框代码,全运行,不报错,就是不显示这个对话框,这是为什么呢?
求大神解答啊!!!!
intentservice是service的子类,这两个除了在消息处理上有点不同,这个为啥差别这么大呢????急啊!!!
intentservice里的部分代码:
protected void onHandleIntent(Intent intent){
_DownloadApkService.requestService();
}
然后在requestService()里会启一个对话框,显示对话框的代码如下:
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(); } }); }