android开发笔记

android开发笔记

ID:26712046

大小:78.50 KB

页数:5页

时间:2018-11-28

android开发笔记_第1页
android开发笔记_第2页
android开发笔记_第3页
android开发笔记_第4页
android开发笔记_第5页
资源描述:

《android开发笔记》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、1.测试案例在xml里面配置:参数targetPackage:运行Action的包名配置:2.打电话的权限Intentintent=newIntent();intent.setAction("android.intent.action.CALL");//intent.addCategory("android.intent.category.

2、DEFAULT");android会自动添加,所以,不用自己添加了intent.setData(Uri.parse("tel:"+number));startActivity(intent);权限配置:3.简单文件的读写publicclassFileService{privateContextcontext;publicFileService(Contextcontext){super();th

3、is.context=context;}//写文件publicvoidsave(Stringname,Stringcontexts)throwsIOException{FileOutputStreamout=context.openFileOutput(name,context.MODE_PRIVATE);out.write(contexts.getBytes());if(out!=null){out.close();}}//读取文件publicStringread(Stringname)throwsIOException{FileInputStre

4、amiis=context.openFileInput(name);ByteArrayOutputStreamatrBuffer=newByteArrayOutputStream();intlenth=0;byte[]buffer=newbyte[1024];while((lenth=iis.read(buffer))!=-1){atrBuffer.write(buffer,0,lenth);}atrBuffer.toByteArray();returnnewString(atrBuffer.toByteArray());}//往SD卡写文件,读写都

5、需要配置权限publicvoidsaveSD(Stringname,Stringcontexts)throwsIOException{Filefile=newFile("/mnt/sdcard",name);FileOutputStreamout=newFileOutputStream(file);out.write(contexts.getBytes());}}文件的操作模式:路径:/date/date/项目名/files/文件名读取sd卡需要权限程序要需要判断if(Environment.getExternalStorageState().equ

6、als(Environment.MEDIA_MOUNTED)){//表示SD卡存在,并且可以读写file.saveSD(name,context);//业务数据}4.pull解析xmlpublicclassPersonService{/***pull解析XML*@throwsXmlPullParserException*@throwsIOException**/publicListgetPersons(InputStreamname)throwsXmlPullParserException,IOException{XmlPullPar

7、serxmlpull=Xml.newPullParser();Listpersons=null;xmlpull.setInput(name,"UTF-8");intevent=xmlpull.getEventType();Personperson=null;while(event!=XmlPullParser.END_DOCUMENT){switch(event){caseXmlPullParser.START_DOCUMENT:persons=newArrayList();break;caseXmlPullParse

8、r.START_TAG:if("person".equals(xmlpull.getName())){int

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。