欢迎来到天天文库
浏览记录
ID:26712046
大小:78.50 KB
页数:5页
时间:2018-11-28
《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
此文档下载收益归作者所有