//去掉窗口標題欄
requestWindowFeature(Window.FEATURE_NO_TITLE);
//全屏顯示 getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
//返回系統Home桌面
Intent intent = new Intent();
//設置Action和Category屬性
intent.setAction(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
startActivity(intent);
//創建Tab
TabHost tabhost = getTabHost();
tabhost.addTab(tabhost.newTabSpec("tab1").setIndicator("已接電話"/*),getResources().getDrawable(R.drawable.icon)*/.setContent(new Intent(this,newACtivity.class)));
//獲取當前app的手機內存位置
// /data/data/包名/files
File file = new File(context.getFiledir(),"info.txt");
//緩存位置
// /data/data/包名/cache
getCacheDir()
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
String data = "http://www.baidu.com":
//解析字符串爲Uri對象
Uri uri = Uri.parse(data);
intent.setData(uri);
//啓動要訪問的瀏覽器頁面
startActivity(intent);
//通過窗口管理器獲取屏幕的寬高
WindowManager mWManger = getWindowManager();
Display display = mWManger.getDefaultDisplay();
DisplayMetrics metrics = new DisplayMetrics();
display.getMetrics(metrics);
//display.getWidth();display.getHeight();已棄用
//獲取屏幕寬高
tableWidth = metrics.widthPixels;
tableHeight = metrics.heightPixels;
//讀寫SD卡上的文件的步驟:
(1)、調用Environment的getExternalStorageState()方法判斷手機上是否插入了SD卡,並且應用程序具有讀寫SD卡的權限。
//如果手機插入了SD卡,並且具有讀寫SD卡的權限,返回true
Environtment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED);
(2)、調用Environment的getExternalStorageDirectory()方法來獲取外部存儲器,也就是SD卡的目錄。
(3)、使用FIleInputStream、FileOutputStream、FileReader或FileWriter讀寫、寫SD卡里的文件。
讀寫SD卡的權限:
<!-- 在SD卡中創建與刪除文件權限 -->
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>
<!-- 向SD卡中寫入數據權限 -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>