Android开发实用代码片段

获取屏幕分辨率:

		DisplayMetrics dm = new DisplayMetrics();
		getWindowManager().getDefaultDisplay().getMetrics(dm);
		int screenHeight = dm.heightPixels;
		int screenWidth = dm.widthPixels;
 

 

 

分享信息:

 

Intent intent = new Intent(Intent.ACTION_SEND);
		intent.setType("text/plain");
		intent.putExtra(Intent.EXTRA_SUBJECT, "来自***(Android版)");
		intent.putExtra(Intent.EXTRA_TEXT, info);
		startActivity(Intent.createChooser(intent, getTitle()));
 

 

 

代码设置全屏:

 

//注意:这两行代码要在setContentView()方法之前调用,否则会报错
requestWindowFeature(Window.FEATURE_NO_TITLE); //不显示标题
		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);//不显示通知栏

你可能感兴趣的:(Android开发)