1.手机屏幕分辨率
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);String strOpt = "手机屏幕分辨率为:" + dm.widthPixels + " × " + dm.heightPixel;
2.调用一个新的Activity,传递Bundle
/* new一个Intent对象,并指定要启动的class */
Intent intent = new Intent();
intent.setClass(EX03_09_1.this, EX03_09.class);
/*new一个Bundle对象,并将要传递的数据传入*/
Bundle bundle = new Bundle();
bundle.putDouble("height",height);
bundle.putString("sex",sex);
/*将Bundle对象assign给Intent*/
intent.putExtras(bundle);
/* 调用一个新的Activity */ startActivity(intent);
/* 关闭原本的Activity */
EX03_09_1.this.finish();
3. 取得Intent中的Bundle对象
/* 取得Intent中的Bundle对象 */
Bundle bunde = this.getIntent().getExtras();
/* 取得Bundle对象中的数据 */
String sex = bunde.getString("sex");
double height = bunde.getDouble("height");
4.选择窗口
new AlertDialog.Builder(EX03_20.this).setTitle(R.string.str_alert_title)
.setItems(R.array.items_irdc_dialog,
new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int whichcountry)
{
CharSequence strDialogBody = getString(R.string.str_alert_body);
String[] aryShop = getResources().getStringArray(
R.array.items_irdc_dialog);
new AlertDialog.Builder(EX03_20.this).setMessage(
strDialogBody + aryShop[whichcountry]).setNeutralButton(
R.string.str_ok, new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog,
int whichButton)
{ /* 在这里处理要作的事 */
}
}).show();
}
}).setNegativeButton("取消", new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface d, int which)
{
d.dismiss();
}
}).show();
5.显示Progress对话框
// 显示Progress对话框
myDialog = ProgressDialog.show(EX03_19.this, strDialogTitle,
strDialogBody, true);
6.调试信息的输出
Log.v(TAG, "This is a VERBOSE message"); //输出冗余消息
Log.d(TAG, "This is a DEBUG message"); //输出调试消息
Log.i(TAG, "This is an INFO message"); //输出普通消息
Log.w(TAG, "This is a WARNING message"); //输出警告消息
Log.e(TAG, "This is a ERROR message"); //输出错误消息