杂记(一)

//去掉窗口标题栏

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"/>





  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值