WindowManager.LayoutParams.TYPE_SYSTEM_ERROR 显示在所有的应用之上包括显示在状态栏上,相对于TYPE_SYSTEM_OVERLAY不能获取焦点更为理想。
另获取状态栏大小的方法可以使用如下方式:
1 public static int getStatusBarHeight(Context context) { 2 int result = 0; 3 int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android"); 4 if (resourceId > 0) { 5 result = context.getResources().getDimensionPixelSize(resourceId); 6 } 7 return result; 8 }
发送邮箱信息可以如下显示:
public static void sendEmail(Context context, String recipient) { sendEmail(context, new String[]{recipient}, null, null, null); } public static void sendEmail(Context context, String[] recipients, String subject, String text, Uri stream) { context.startActivity(createSendEmailIntent(recipients, subject, text, stream)); } public static Intent createSendEmailIntent(String[] recipients, String subject, String text, Uri stream) { Intent i = new Intent(Intent.ACTION_SEND); i.setType("message/rfc822"); if (recipients != null) { i.putExtra(Intent.EXTRA_EMAIL, recipients); } i.putExtra(Intent.EXTRA_SUBJECT, subject); if (!TextUtils.isEmpty(text)) { i.putExtra(Intent.EXTRA_TEXT, text); } if (stream != null) { i.putExtra(Intent.EXTRA_STREAM, stream); } return i; }