在任何应用程序弹出窗口 [英] Popup window in any app
本文介绍了在任何应用程序弹出窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想弹出在特定时间对话框中的任何应用程序,我的code:
i want to Popup dialog at a specific time in any app my code :
public class testPOPDialog extends Activity {
/** Called when the activity is first created. */
private Handler mHandler = new Handler();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mHandler.postDelayed(mUpdateTimeTask, 1000);
}
private Runnable mUpdateTimeTask = new Runnable() {
public void run() {
AlertDialog d = new AlertDialog.Builder(testPOPDialog.this)
.setTitle("tanchulai")
.setMessage("bucuo de tanchulai")
.create();
d.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
d.show();
}
};
}
它给我
12-03 10:12:18.162: ERROR/AndroidRuntime(571): android.view.WindowManager$BadTokenException: Unable to add window android.view.ViewRoot$W@43dd71c0 -- permission denied for this window type
这是什么权限
如果我删除 d.getWindow()的setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
我的应用程序是正确的......
what is this permission
if i delete d.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
my app is correct.....
推荐答案
将此权限您的清单:
android.permission.SYSTEM_ALERT_WINDOW
这篇关于在任何应用程序弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文