本文整理了Java中android.view.Window.setType()
方法的一些代码示例,展示了Window.setType()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Window.setType()
方法的具体详情如下:
包路径:android.view.Window
类名称:Window
方法名:setType
暂无
代码示例来源:origin: behindeye/WxPhoneNumberHelper
public void setSystemLevel() {
this.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
}
}
代码示例来源:origin: pranavpandey/dynamic-support
/**
* Bind the dialog with a window token. Useful to display it from a service.
*
* @param dialog The dialog to be displayed.
* @param type The dialog type.
*
* @return The bound dialog with the supplied view.
*/
public static Dialog bindDialog(@NonNull Dialog dialog, int type) {
Window window = dialog.getWindow();
if (window != null) {
window.setType(type);
window.setWindowAnimations(android.R.style.Animation_InputMethod);
window.addFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
}
return dialog;
}
}
代码示例来源:origin: stackoverflow.com
final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this, R.style.AppTheme_MaterialDialogTheme);
dialogBuilder.setTitle(R.string.dialog_title);
dialogBuilder.setMessage(R.string.dialog_message);
dialogBuilder.setNegativeButton(R.string.btn_back,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
}
);
final AlertDialog dialog = dialogBuilder.create();
final Window dialogWindow = dialog.getWindow();
final WindowManager.LayoutParams dialogWindowAttributes = dialogWindow.getAttributes();
// Set fixed width (280dp) and WRAP_CONTENT height
final WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
lp.copyFrom(dialogWindowAttributes);
lp.width = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 280, getResources().getDisplayMetrics());
lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
dialogWindow.setAttributes(lp);
// Set to TYPE_SYSTEM_ALERT so that the Service can display it
dialogWindow.setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
dialogWindowAttributes.windowAnimations = R.style.DialogAnimation;
dialog.show();
代码示例来源:origin: chunquedong/axbasePlugin
public void onUpdate(String id, String whatsNew) {
String title = getApplicationName() + "已更新,应用需要重启";
String msg = whatsNew + "\n(Powered by axbase插件系统)";
if (PluginClient.config.forceRestart != 0){
AlertDialog.Builder builder = new AlertDialog.Builder(context)
.setTitle(title).setMessage(msg).setCancelable(false)
.setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
restartApp();
}
});
if (PluginClient.config.forceRestart == 2) {
builder.setNegativeButton("取消", null);
}
AlertDialog alert = builder.create();
alert.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
alert.show();
} else {
showMessage(title+msg);
}
}
代码示例来源:origin: PuffOpenSource/Puff-Android
private void initUI(){
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
int width = metrics.widthPixels / 10 * 9;
int height = metrics.heightPixels / 3 * 2;
getWindow().setLayout(width,
height);
getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
}
代码示例来源:origin: AndroidFriendsGroup/FRDialog
if (isInService) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
Objects.requireNonNull(window).setType(WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY - 1);
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
Objects.requireNonNull(window).setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
代码示例来源:origin: werbhelius/MyCalendarDemo
private void showAlarmDialog(Context context, AlarmBean bean) {
vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
playMusicAndVibrate(context,bean);
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle("距离您定的日期 "+bean.getTitle()+" 已经到了哦!")
.setMessage(bean.getDescription())
.setPositiveButton("我知道了", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (mediaPlayer != null) {
mediaPlayer.stop();
mediaPlayer.release();
mediaPlayer = null;
if(isVibrator){
vibrator.cancel();
isVibrator = false;
}
}
}
});
AlertDialog dialog = builder.create();
dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
dialog.show();
}
代码示例来源:origin: andstatus/andstatus
public static Dialog showOkAlertDialog(Object method, Context context, @StringRes int titleId, CharSequence summary) {
final AlertDialog dialog = new AlertDialog.Builder(context)
.setIcon(android.R.drawable.ic_dialog_alert)
.setTitle(titleId)
.setMessage(summary)
.setPositiveButton(android.R.string.ok,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int whichButton) {
dialog.dismiss();
}
}).create();
if (!Activity.class.isAssignableFrom(context.getClass())) {
// See http://stackoverflow.com/questions/32224452/android-unable-to-add-window-permission-denied-for-this-window-type
// and maybe http://stackoverflow.com/questions/17059545/show-dialog-alert-from-a-non-activity-class-in-android
dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_TOAST);
}
try {
dialog.show();
} catch (Exception e) {
try {
MyLog.e(method, "Couldn't open alert dialog with the text: " + summary, e);
Toast.makeText(context, summary, Toast.LENGTH_LONG).show();
} catch (Exception e2) {
MyLog.e(method, "Couldn't send toast with the text: " + summary, e2);
}
}
return dialog;
}
代码示例来源:origin: Tornaco/SystemRecApi
.create();
alertDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
alertDialog.show();
代码示例来源:origin: stackoverflow.com
final Dialog dlg = new Dialog(this);
View action_layout = ((LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE)).inflate(R.layout.contacts_action, null);
dlg.requestWindowFeature(Window.FEATURE_NO_TITLE);
Window window = dlg.getWindow();
window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
window.setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
WindowManager.LayoutParams wlp = window.getAttributes();
wlp.gravity = Gravity.FILL_HORIZONTAL;
window.setAttributes(wlp);
dlg.setCancelable(true);
dlg.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
dlg.setContentView(action_layout);
dlg.show();
代码示例来源:origin: smartdevicelink/sdl_android
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTitle(TAG);
w = getWindow();
startRefreshTask();
w.setType(WindowManager.LayoutParams.TYPE_PRIVATE_PRESENTATION);
}
代码示例来源:origin: weex-plugins/amap-running-app
mDevOptionsDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
mDevOptionsDialog.show();
代码示例来源:origin: yuan-gao/zhihuDaily-Weex
mDevOptionsDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
mDevOptionsDialog.show();
代码示例来源:origin: QDqiaodong/Reader
@Override
public Presentation initPresentation() {
DisplayManager displayManager = (DisplayManager) mContext.getSystemService(Context.DISPLAY_SERVICE);
Display[] presentationDisplays = displayManager
.getDisplays(DisplayManager.DISPLAY_CATEGORY_PRESENTATION);
if (presentationDisplays.length > 0) {
Display presentationDisplay = presentationDisplays[0];
mPresentation = new PdfPresentation(mContext, presentationDisplay);
mPresentation.getWindow().setType(
WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
SystemPropertyUtils.setSystemProperty(mContext, "sys.eink.Appmode", "13");
mPresentation.show();
return mPresentation;
}
return null;
}
代码示例来源:origin: PuffOpenSource/Puff-Android
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_authorize);
getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
mPasswordView = (EditText) findViewById(R.id.password);
mPasswordView.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent) {
if (id == R.id.login || id == EditorInfo.IME_NULL) {
attemptLogin();
return true;
}
return false;
}
});
Button mEmailSignInButton = (Button) findViewById(R.id.email_sign_in_button);
mEmailSignInButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
attemptLogin();
}
});
mLoginFormView = findViewById(R.id.login_form);
mProgressView = findViewById(R.id.login_progress);
}
代码示例来源:origin: XiqingLiu/JesStatistics
window.setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
window.setContentView(R.layout.dialog_statistics_des);
WindowManager.LayoutParams params = window.getAttributes();
代码示例来源:origin: techstar-cloud/memorize-en
@Override
protected void onCreate(Bundle arg0) {
super.onCreate(arg0);
sLockscreenActivityContext = this;
mMainHandler = new SendMassgeHandler();
// getWindow().setType(2004);
// getWindow().addFlags(524288);
// getWindow().addFlags(4194304);
///
getWindow().setType(WindowManager.LayoutParams.FLAG_FULLSCREEN);
// getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
} else {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
}
TelephonyManager manager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
manager.listen(phoneStateListener, PhoneStateListener.LISTEN_CALL_STATE);
initLockScreenUi();
setLockGuard();
}
内容来源于网络,如有侵权,请联系作者删除!