delphi xe6andriod编程入门教程_第1页
delphi xe6andriod编程入门教程_第2页
delphi xe6andriod编程入门教程_第3页
delphi xe6andriod编程入门教程_第4页
delphi xe6andriod编程入门教程_第5页
已阅读5页,还剩273页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

引 DelphiXE6.......................................................................................................................进入DelphiXE6开发环 Delphi项目开发环境的组 原代码格式化 待办(TO-DO 完成类别功能(ClassCompletion) 错误提示(Error 变量(Declare 设定和使 DelphiXE6资 字符串的处理单元 资料性附录:IOUtils单元使用测 资料性附录:Androidpermission权限大 使用数据 让TRectangle显示........................................................................................................ 更新数据库数据(含BlobField使用 34与回放( 38音乐和...................................................................................................................... 异步从网上载入.............................................................................................................. 47小写转大 delphi,而且不喜欢非可视化编程,相信大多数delphi者都和我一样吧。好在3个月前,我试用了一下DelphiXE5绿色版本(网址 方法一:从iny的帖子h /s/1nt9bmOh安装时,电脑里不曾安装其它delphi。安装Windows 行32、dexplorelp.exe);执行 下的XE6Green.exe(先关闭杀毒软件和,DelphiXE6DelphiXE6DelphiXE6图像开始执行DelphiXE6开发环境:DelphiXE6环境,你会看到类似如下的画面,DelphiXE6环境除了菜单和工具3321451 2345VCLForms5建立HDFireMonkeyApplication:33215412345或者同时按下[Shift+Ctrl+S]3个按键保存项目,当保存项目时开发环境会询问以什么名在保存项目时,你可以选择保存在一个特定的中,例如“F:\Myandroidprograms\DelphiXE6andriod编程\demo\1.2DelphiXE6”,如果你直接保存项目而没有选择特定的,那么DelphiIDE会的项目保存在C:\Users\你的名称\s\RADStudio\Projects\的内定之下Delphi的项目是由不同的文件和相关的设定所组成,其中主要的元素就是窗体“Form”编写你应用程序逻辑程序代码的元素。在FireMonkey类型项目中,窗体是以“.fmx”结尾模式。而“targettforms”则可设定项目编译的目标平台,由于FireMonkey项目可支持88下图显示了在控件面板中查找TEdit控件:99|3种方式是使用“IDEInsight”功能,“IDEInsight”能够让你查找开发环境中任何的F6键或“ctrl+.searchIDEInsight,开发环境即会将输入焦点移动到“IDEInsight”输入框(在屏幕的右上角IDEInsightF6TEdit即可找到TEdit控件,接着TEditTEdit加入窗体中,使用“IDEInsightTEdit请注意“IDEInsight”会根据你现在使用的模式来查找内容,例如如果你是在程序代码且双击其中的OnCreate,如下所示:标自动停留在空白的处理函数程序区块中,准备让你编写程序代码。29Edit1控件中写入“当程序一运行时,我就现在你就可以试着执行此范例应用程序了,你可以点击中的“RunWithoutDelphi开Delphi开发应用程序很简单,不是onCreate(当窗口被创建时)中执行的代码,框是会比主窗口先显示FireMonkeyFireMonkey示例应用程序编译在Targettforms节点中看到目前应用程序的目标平台是Win32:TargettformsFireMonkey支持的平台都可以,请你点击Targettforms节点,再点击鼠标右键,再选择“Addtform…”菜单,请在上面的框中选择64-bitWindows选项然后点击[OK]按钮,你就可以在Targettforms节点中看到新增的64-bitWindows子节点,如下所示:序就会自动编译成原生的64位应用程序。当然,我的机器是32位的,无法运行:FireMonkey框架开发应用程序的好处就是你只需要编写一份程序代码就可以同时接下来让我们看看如何使用按键来移动程序代码区块。首先把光标移动到下图29行左Shift2行程序代码选择,此时编辑器会以反白显示被选择的程序区块,或是直接使用鼠标选择这2行程序区块,接着同时按下, 请试着在此下拉框中选择不同的组态,例如先选择“DefaultLayout”,你会发现此时开<Classic<Debug原代码格式化接着IDE会显示一个框询问你是否确定要格式化源代码,“Yes“按钮,或是顺便勾选框中的复选项,避免每次要格式化源代码时IDE都会询问你。点击“Yes“按钮之后,IDE便会开始格式化你的源代码,下图就是格式化之后的结果,上方菜单中的Tools|Options…选项启动Options框,然后在其中找寻Formatter|Delphi10个如何格式化源代码的设定,你可以使用这些设定来定义你的代码,在其中使用了bbccstring类型的变量:使用bb和cc实在不是很好名习惯,因为看不出来它的意义,因此让我们改变bbffirst_strlast_strbbcc大量使用在程序代码中,SyncEditbbccffirst_strlast_str。首先请如下图选择整个代码(Shift+↓键ffirst_str(注意:修改过的代码在未保存标记中显示为黄色)如下所示:1次按下“Tab”键方框反白标示就会停留在cc上,你就可以像刚才修改bb为ffirst_strcc的名称。假设现在我们想把原先Button2Click中的程序代码改在另外一个称为GetAFileName的程序中,那么要如何修改Button2Click程序呢?当然你可以GetAFileName程序,再把试着使用IDE提供的程序代码重构功能来安全的完成这个工作。IDE上方的Refactor|ExtractMethod…菜单,或是同时按下“Shift+Ctrl+M”3个键。接着IDE会显示ExtractMethod框,框下方会显示所有会被重构的程序代码,称,如下所示,请在Newmethodname字段中输入GetAFileName: 待办(TO-DO现这些待办,你也可以追踪,管理程序代码中的待办以便了解你是否完成了所有的要在编辑器中加入待办,你可以在程序代码中适当的地方同时按下Shift+Ctrl+T,或是在编辑器上点击鼠标右键,在快捷菜单中选择“AddTo-Doitem…”选项。例如由于前GetAFileName程序只是一个方法,应该改成一个函数,以便让其更具有通用性,的第1行程序代码之上,同时按下Shift+Ctrl+T准备加入待办,此时IDE就会显示一个 FormCreate程序中使用刚才相同的方法加入一另外一个待办待办事项。完IDEView/TO-DoList菜单,你就可以看到类似如下的画面,IDE按下F2键,那么EditTo-DoItem框就会显示,你就可以进行修改。我们只需要勾选待办事项最左方的复选框,那么IDE就会修改程序代码中的待办事项为完成类别功能(ClassCompletion)现在让我们在类别中一个函数ReceText,请移动光标到程序代码上方类别的private处并且如下编写ReceText程序以及它的参数。接着同时按下“CTRL+SHIFT+C”3个键,(或在函数处点击右键,从快捷菜单中选Cursor)IDE加入ReceText程序,如下所示:错误提示(ErrorTempStr变量下方会出现一条红线,如果你把TempStr变量上方,IDE就会显示如上来“Undeclaredidentifier‘TempStr’”信息。而TempStr变量下方的红线称为“错误提示”,这是因为TempStr变量尚未在程序代码,因此“错误提示”以红线提醒你,现在就让我们TempStr变量以修正这个错误。变量(Declare再选择“DeclareVariable…”选项,如下所示,或是直接同时按下“Shift+Ctrl+V态为TStringDynArray,“OK”按钮接受: 可以采用word常用的“替换”功能来实现。IDE上方的Search|Rece…菜单,如利用IDE的书签功能。Ctrl+Shift+0,Ctrl+Shift+1一直到Ctrl+Shift+9最多设定10个书签。就可以如下图看到IDE在编辑器最左边出现了一个『2』的标志,这就代表你在这行程序代就可以如下图看到IDE在编辑器最左边出现了一个『3』的标志,这就代表你在这行程序代Ctrl+2GetAFileName1行程序代Ctrl+3FormGreate1行程同时按下“CTRL+SHIFT+SPACE”3个键就可以启动编辑器的“程序代码参数提示”功能,编辑器就会显示ReceText函数所有接受的参数信息,如上所示。History子,其中子中保存一份版本,因此这个History子中所有的文件便是你对项目修改的历程,也就是说IDE会在这个History子提供一些类似版本控制软件提供的功能。DelphiXE6资字符串的处理单元 /del/)functionToLower:functionToLower(LocaleID:TLocaleID):string;functionToLowerInvariant:string;functionToUpper:functionToUpper(LocaleID:TLocaleID):string;functionToUpperInvariant:string;classfunctionLowerCase(constS:string):string;classfunctionLowerCase(constS:string;LocaleOptions:TLocaleOptions):string;classfunctionUpperCase(constS:string):string;classfunctionUpperCase(constS:string;LocaleOptions:TLocaleOptions):string;str:=str:=str.ToLower;//delphistr:=str.ToUpper;//functionTrim:string;functionTrimLeft:string;functionTrimRight:string;functionTrim(constTrimChars:arrayofChar):string;functionTrimLeft(constTrimChars:arrayofChar):string;functionTrimRight(constTrimChars:arrayofChar):string;str1,str2:string;str1:= Delphi str2:=str1.TrimLeft;//'Delphi10000'str2:=str1.TrimRight;//'Delphi10000'str2:=str1.Trim;//'Delphi10000'str2:=str1.Trim(['','0']);//'DelphifunctionCompareTo(conststrB:string):classfunctionCompare(constStrA:string;constStrB:string):classfunctionCompareText(constStrA:string;constStrB:string):classfunctionCompare(constStrA:string;constStrB:string;LocaleID:TLocaleID):Integer;classfunctionCompare(constStrA:string;constStrB:string;IgnoreCase:Boolean):Integer;classfunctionCompare(constStrA:string;constStrB:string;IgnoreCase:Boolean;LocaleID:TLocaleID):Integer;string;IndexB:Integer;Length:Integer):string;IndexB:Integer;Length:Integer;LocaleID:TLocaleID):string;IndexB:Integer;Length:Integer;IgnoreCase:Boolean):string;IndexB:Integer;Length:Integer;IgnoreCase:Boolean;LocaleID:TLocaleID):Integer;classfunctionCompareOrdinal(constStrA:string;IndexA:constStrB:string;IndexB:Integer;Length:Integer):str1,str2:string;n:Integer;str1:='ABCstr2:='abcn //-n pare(str1, //n pareText(str1, 0n pare(str1str2 0n pareOrdinal(str1, //-n pare(str14str243)0functionIndexOf(value:Char):functionIndexOf(constValue:string):functionIndexOf(Value:Char;StartIndex:Integer):Integer;functionIndexOf(Value:Char;StartIndex:Integer;Count:Integer):functionIndexOf(constValue:string;StartIndex:Integer;Count:Integer):Integer;functionIndexOfAny(constAnyOf:arrayofChar):Integer;Count:Integer):Integer;functionLastIndexOf(Value:Char):functionLastIndexOf(constValue:string):functionLastIndexOf(Value:Char;StartIndex:Integer):Integer;functionLastIndexOf(constValue:string;StartIndex:Integer):functionLastIndexOf(Value:Char;StartIndex:Integer;Count:Integer):Integer;Integer):Integer;functionLastIndexOfAny(constAnyOf:arrayofChar):Integer;functionLastIndexOfAny(constAnyOf:arrayofChar;StartIndex:Integer):Integer;functionLastIndexOfAny(constAnyOf:arrayofChar;StartIndex:Integer;Count:Integer):Integer;n:Integer;str:='A1A2A3n:=str.IndexOf('A'); //0n:=str.LastIndexOf('A');//n 1n:=str.IndexOf('A',1,str.Length-1); //3n:=str.LastIndexOf('A',str.Length-1,str.Length-1);//9n:=str.IndexOfAny(['1','2','3', //n:=str.LastIndexOfAny(['1','2','3','4']);//functionContains(constValue:string):functionStartsWith(constValue:string):functionStartsWith(constValue:string;IgnoreCase:Boolean):functionEndsWith(constValue:string):classfunctionEndsText(constASubText,AText:string):b:Boolean;str:='Delphib:=str.Contains('XE');//Trueb:=str.Contains('xe');//b:=str.StartsWith('delphi'); b:=str.StartsWith('delphi',True);//Trueb:=str.EndsWith('XE4'); //Trueb:=str.EndsText('xe4', //functionQuotedString:functionQuotedString(constQuoteChar:Char):functionDeQuotedString:functionDeQuotedString(constQuoteChar:Char):str1,str2:string;str1:=str2:=str1.QuotedString; //'Delphi'str2:= //str1:=str2:=str1.DeQuotedString('"');//functionPadLeft(TotalWidth:Integer):functionPadLeft(TotalWidth:Integer;PaddingChar:Char):string;functionPadRight(TotalWidth:Integer):string;functionPadRight(TotalWidth:Integer;PaddingChar:Char):str:=str:=str.PadLeft(4,'0');//functionInsert(StartIndex:Integer;constValue:string):functionRemove(StartIndex:Integer):functionRemove(StartIndex:Integer;Count:Integer):str1,str2:str1:='Delphistr2:=str1.Insert(7,'XE');//Delphistr1:='Delphistr2:=str1.Remove(6); //Delphistr2:=str1.Remove(7,2);//Delphi4截取functionSubstring(StartIndex:Integer):functionSubstring(StartIndex:Integer;Length:Integer):str1,str2:string;str1:='Delphistr2:=str1.Substring(7); str2:=str1.Substring(7,2);//XE替换functionRe ce(OldChar:Char;NewChar:Char):string;functionRe ce(OldChar:Char;NewChar:Char;ReceFlags:TReceFlags):string;functionRece(constOldValue:string;constNewValue:functionRe ce(constOldValue:string;constNewValue:string;ReceFlags:TReceFlags):string;str1,str2:string;str1:='ABCABCstr2:=str1.Re ce('A','*'); //*BC*BC*BCstr2:=str1.Re ce('A','*',[rfIgnoreCase]);//*BCABCABC分割functionSplit(constSeparator:arrayofChar):TArray<string>;functionSplit(constSeparator:arrayofChar;Count:Integer):functionSplit(constSeparator:arrayofChar;Options:TStringSplitOptions):TArray<string>;functionSplit(constSeparator:arrayofstring;Options:TStringSplitOptions):TArray<string>;TStringSplitOptions):TArray<string>;functionSplit(constSeparator:arrayofstring;Count:Integer;Options:TStringSplitOptions):TArray<string>;str:arr:str:='A-1,B-2,,,C-3,D-arr:=str.Split([',']); //arr[0]=A-1;Length(arr)=6arrstr.SplitTStringSplitOptions.ExcludeEmpty忽略空项Length(arrarrstr.Split(2);=arrstr.Split( 连接classfunctionJoin(constSeparator:string;constvalues:arrayofconst):string;classfunctionJoin(constSeparator:string;constValues:arrayofstring):string;classfunctionJoin(constSeparator:string;constValues:IEnumerator<string>):string;classfunctionJoin(constSeparator:string;constValues:IEnumerable<string>):string;classfunctionJoin(constSeparator:string;constvalue:arrayofstring;StartIndex:Integer;Count:Integer):string;S:string;strArr:str:=strArr:=str.Split([','],str:=S.Join('-', str:=S.Join(';', //1;2;3;4;str:=S.Join(',',['abc',123,true]);//functionToBoolean:Boolean;functionToInteger:Integer;functionToSingle:Single;functionToDouble:Double;functionToExtended:Extended;classfunctionToBoolean(constS:string):Boolean;classfunctionToInteger(constS:string):Integer;classfunctionToSingle(constS:string):Single;classfunctionToDouble(constS:string):Double;classfunctionToExtended(constS:string):Extended;classfunctionParse(constValue:Integer):string;classfunctionParse(constValue:Int64):string;classfunctionParse(constValue:Boolean):string;classfunctionParse(constValue:Extended):string;S:string;n:Integer;b:Boolean;f:Double;str:=n:=str.ToInteger;//123b:=str.ToBoolean;//str:=b:=str.ToBoolean;//Truen:=str.ToInteger;//-1str:=S.Parse(3. f:=str.ToDouble;//3.定界符functionIsDelimiter(constDelimiters:string;Index:Integer):functionLastDelimiter(constDelims:string):b:Boolean;n:Integer;str:= b:=str.IsDelimiter(':',4);//Trueb:=str.IsDelimiter('//',5);//n:=str.LastDelimiter('.'); n:= //constEmpty=functionIsEmpty:classfunctionIsNullOrEmpty(constValue:string):classfunctionIsNullOrWhiteSpace(constValue:string):S:string;b:str:= b:=str.IsEmpty; //Falseb:=S.IsNullOrWhiteSpace(str);//String与classfunctionCreate(C:Char;Count:Integer):Length:Integer):string;classfunctionCreate(constValue:arrayofChar):propertyChars[Index:Integer]:CharreadpropertyLength:IntegerreadfunctionCountChar(constC:Char):functionToCharArray:functionToCharArray(StartIndex:Integer;Length:Integer):DestinationIndex:Integer;Count:Integer);S:str,str2:string;n:Integer;c:str:=n:= //c:=str.Chars[0];//A=str:=S.Create('A',7);//AAAAAAAcharArr:='ABCDEFG'.ToCharArray;str:=s.Create(charArr); str:=S.Create(charArr,1,3);//BCDcharArr:=' str:='ABCDEFG';str.CopyTo(1,charArr,2,str:= //其他functionEquals(constValue:string):functionGetHashCode:classfunctionEquals(consta:string;constb:string):classfunctionCopy(constStr:string): 9、安卓能够运行的程序(我们成功编译出的程序)在如下文件夹内:后缀不变)文件拷贝到的根下(别告诉我不会,就像把文件拷贝到U盘一样),用的文件管理器程序打开该文件,直接安装即可。我用的为努比亚Z5,运行效果(MTP盘,只是这种方式比老机器的U盘模式要好,原来的U盘模式可能会让的程序无法使用存贮卡内的数据,但这种方式不会。简单点,选择这个,就是U盘。UUPTP调制解调器,选择这个,就是电脑通过的sim卡或wifi来上网。前提是确保此话咨询USB调试模式,在弹出的警告窗口中点击确定,如下图所示:5、如果成功看到上一步的图形中的型号,你再编译你的程序,你会发现,不会出机屏幕亮着,如果屏幕是锁着的,可能会出现程序自动运行时的假死情况,当然你也总之,如果你能够找到驱动程序,建议用这种方法,如果找不到,那就直接当盘用,把编译好的程序直接拷贝到,再通过安装也一样很快。MainActivity.finish}{$IFDEFApplication.MainForm.DisposeOf;{}procedureTForm1.FormKeyUp(Sender:TObject;varKey:Word;varKeyChar:Char;Shift:TShiftState);ifKeyvkHardwareBackthen//如果按下物理返回键ifMessageDlg('确认退出吗?',TMsgDlgType.mtConfirmation,[TMsgDlgBtn.mbOKTMsgDlgBtn.mbCancel1mrOKthenMainActivity.finish;{退出程序}调试方法同前,将Project1.apk文件拷贝到的根 {$IFDEFFMX.Ani,::FWantExitfalse。3、写主窗口的Close(windows下用的,中不写也可以)procedureTForm1.FormClose(SenderTObjectvarActionTCloseAction);{$IFDEFifnotFWantExitthenAction:=TCloseAction.caNone;FWantExit:=procedureTForm1.FormKeyUp(Sender:TObject;varKey:Word;varKeyChar:Char;Shift:TShiftState);{$IFDEFif(Key=vkHardwareBack)thenifnotFWantExitthenKey:=FWantExit:=True;Delay:=if(TControl(Parent).Opacity=1)thenFWantExit:=notprocedureAniInit(A:TFloatAnimation);Name:='Ani';StartValue:=0;Delay:=Duration:=0;functionFind(ACName:string;ACClass:TComponentClass;AOwner:TComponent):Result:= ifnotAssigned(Result)thenResult:=withLRdoif(Name='')thenXRadius:=1;YRadius:=Fill.Color:=TAlphaColorRec.Black;HitTest:=False;Parent:=GlowColor:=Parent:=LR;Font.Size:=12;Align:=TAlignLayout.al;withTText( LR.Width:=Canvas.TextWidth(AStr)+35;LR.Position.X:=(Self.Width-LR.Width)/2;LR.Position.Y:=(Self.Height-LR.Height)/1.25;找到RADStudioXE6下的FMX.Consts.pas文件(我的在F:\RADStudioXE6\source\fmx\FMXConsts.pa,将其拷贝到程序根,并加入到工程中后,打开该文件{DialogStrings}SMsgDlgWarning='警告';SMsgDlgError='错误';SMsgDlgConfirm='确认';SMsgDlgYes='是的';SMsgDlgNo='不是';SMsgDlgOK='确定';SMsgDlgCancel='取消';SMsgDlgHelp='帮助';SMsgDlgHelpNone没有提供帮助';SMsgDlgHelpHelp='帮助';SMsgDlgAbort='放弃';SMsgDlgRetry='重试';SMsgDlgIgnore='忽略';SMsgDlgAll='全部';SMsgDlgYesToAll='全选“是”';SMsgDlgClose='关闭';SWindowsVistaRequiredsWindowsVista或以上操作系统';SUsername='&用户名';SPassword='& ='&Android\Release\FMX.Consts.o文件和一个Android\Release\FMX.Consts.dcuRADStudioXE6 usesclose;隐藏第二个窗口 1、delphi原来的方法:弹出一个框。 ifMessageDlg('你喜欢我吗?TMsgDlgType.mtConfirmation,[TMsgDlgBtn.mbYes,TMsgDlgBtn.mbNo],-1)=mrYesthen '谢谢你喜欢我,我也很喜欢你!。msresultFMX.Dialogs.InputBox('询问你多大了?10岁了。');showmessage('你输入的是:'+msresult);android.toast.pas的代码如下:unitandroid.toast;FMX.Types,FMX.Ani,FMX.Objects,FMX.Forms,FMX.Effects,System.UITypes,System.Math;Rect_Padding_Hor=15; txtToast:TText;sdeToast:TShadowEffect;destructorDestroy;classprocedureMakeText(AParentForm:TForm;constAMsg:String;txtToast.Text计算文本的宽度和高度txtToast.Color:=TAlphaColorRec.White;txtToast.Font.Size:=11;retToast:=TRectangle.Create(AOwner);retToast.Padding.Left:=Rect_Padding_Hor;retToast.Padding.Right:=Rect_Padding_Hor;retToast.Padding.Top:=Rect_Padding_Ver;retToast.Fill.Color:=$FF1D1616;retToast.Parent:=AOwner;aniToast:=TFloatAnimation.Create(AOwner);aniToast.Parent:=retToast;aniToast.PropertyName:='Opacity';aniToast.StartValue:=1;aniToast.StopValue:=0;aniToast.Loop:=false;aniToast.OnFinish:=ToastAnimationFinish;sdeToast.Parent:=retToast;sdeToast.Direction:=45;sdeToast.Softness:=0.2; classprocedureTToast.MakeText(AParentForm:TForm;constAMsg:String;AShowTimeLong:TToastLengthValue;iscenter:Boolean=True);toast.txtToast.Text:=AMsg;toast.txtToast.Width:=max(0,AParentForm.Width-(50+Rect_Padding_Hor)*2);toast.txtToast.Height:=max(0,AParentForm.Height-(20+Rect_Padding_Ver)*2);toast.txtToast.WordWrap:=true;toast.retToast.Width:=toast.txtToast.Width+Rect_Padding_Hor*2;toast.txtToast.Parent:=toast.retToast;ifiscenterthen Rect_Padding_Ver*2);toast.aniToast.Enabled:=true;toast.retToast.Visible:=true;toast.txtToast.Visible:=true; self.;路径操作使用TPath的方法都很方便。 (/)TPathWindows,Mac,iOS,Android上showmessage('GetCachePath:'+TPath.GetPathRoot(TPath.GetCachePath));showmessage('GetTempPath:'+TPath.GetTempPath);showmessage('GetHomePath:'+TPath.GetHomePath); sPath:'+TPath.Get sPath:'+TPath.GetShared showmessage('GetSharedPicturesPath:'+TPath.GetSharedPicturesPath);showmessage('GetSharedDownloadsPath:'+TPath.GetSharedDownloadsPath);showmessage('GetCachePath:'+TPath.GetCachePath);showmessage('GetCameraPath:'+TPath.GetCameraPath);showmessage('GetPicturesPath:'+TPath.GetPicturesPath);showmessage('GetPublicPath:'+TPath.GetPublicPath);以下是用nubia 但一 会是(如魅族MX但一 会是(如魅族MX 注:保存在TPath.GetTempPath file1:='/storage/sdcard0/Gushidawang/'+afilename+'.ml';filemap:='/storage/sdcard0/Gushidawang/cover/'+afilename+'.jpg';file2:=temppath+afilename+'.mp3';filemap:='/storage/sdcard1/Gushidawang/over/'+afilename+'.jpg';ifnottfile.Exists(file1)thenfile1:='/mnt/sdcard/Gushidawang/'+afilename+filemap:='/mnt/sdcard/Gushidawang/over/'+afilename+'.jpg';ifnottfile.Exists(file1)then,'//ifnotTDirectory.Exists(temppath)then//将文件拷贝到指定位置ifnotTfile.Exists(file2)thenTfile.Copy(file1,file2);files://forI:=0tohigh(files)do SD卡文件 5、dataAndroid 。 机软件拍出的相片也会保存在这里,比如360或晕影相机等。 会占用SD卡较大内存。 5、.ucdlres:UC迅雷的缓存文件。 sToGo的相关文件夹。9、gameloft:gameloft游戏数据包存放的文件夹。12、ireader:ireader的缓存文件夹。清 25、TalkingFriends:talkingtom(会说话的tom猫)录制的文件所保存的 ,比如QQ。(与上面的.QQ文件夹并不相同) 器 36、apadqq-images:QQforpad的缓 yerPro:是MOBO等器使用后的记录定期删除。((

bak文件。资料性附录:IOUtils用IOUtils单元下的TDirectory.GetFiles获取文件列表太方便了,下面的例子只是usesIOUtils,constpath='C:\ProgramFiles\Embarcadero\RAD dir:TDirectory;{这是个结构,后面就不再了,将直接使用files:TStringDynArray;{TStringDynArray=arrayofstring;}str:string;files:=dir.GetFiles(path);forstrinfilesdo str:string;files:=TDirectory.GetFiles(path,'*.txt');forstrinfilesdo procedureTForm1.Button3Click(Sender:TObject);str:string;files:=TDirectory.GetFiles(path,'*.txt',forstrinfilesdo//TDirectory.GetFilesTDirectory.TFilterPredicate类型的参数,这是个函数类型,可对搜索结果再处理functionfp(constPath:string;constSearchRec:TSearchRec):Form1.Memo1.Lines.Add(Path+'\'+files:files:=TDirectory.GetFiles(path,files:files:=TDirectory.GetFiles(path,'*.txt',files:files:=TDirectory.GetFiles(path,'*.txt',TSearchOption.soAllDirectories,fp);files:files:=function(constPath:string;constSearchRec:Memo1.Lines.Add(Path+'\'+ 下有Li开头的文files:files:=TDirectory.GetFiles(path,'Li*.*');forstrinfilesdo//获取指定及其子下文件名只有3pas文件procedureTForm1.Button2Click(Sender:TObject);str:string;files:=TDirectory.GetFiles(path,'???.pas',forstrinfilesdo str:string;forstrindfsdo 下的、名称是L开头的文件与str:string;dfs:=TDirectory.GetFileSystemEntries(path,'L*');forstrindfsdo str:string;dfs:=TDirectory.GetFileSystemEntries(path+'\source',TSearchOption.soAllDirectories,nil);forstrindfsdo//使用TDirectory.TFilterPredicate函数参数procedureTForm1.Button4Click(SenderTObject);dfs:dfs:=function(constPath:string;constSearchRec:Memo1.Lines.Add(Path+'\'+ {删除文件夹True可删除 的根盘符,如:C:\}TDirectory.GetCurrentDirectory;{获取当前 TDirectory.SetCurrentDirectory();{设置当前 {获取驱动器列表;下有举例} {获取文件夹属性,譬如只读存档等;下有 {使用Utc时间格式或设置}//TDirectory.GetLogicalDrives;{获取驱动器列表}procedureTForm1.Button1Click(SenderTObject);s:arr:forsinarrdofa:TFileAttribute;fas:=TDirectory.GetAttributes('c:\Windows');forfa:=Low(TFileAttribute)toHigh(TFileAttribute)doiffainfasthenpath=以后路径相关的处理IOUtils.TPath {提取盘符如 {更换扩展名} {用于产生一个唯一的文件名,布尔参数决定名称中是否包含-} //属性,获取在不同平台下的各种路径分隔符,都是只读的. {Windows下是"."} {Windows下是";"} {Windows下是":"}IOUtils单元主要就是三个结构TDirectory、TPath、TFile,很有用;TFile的TFile.Copy(source,dest); TFile.Copy(source,dest,True);{将覆盖同名的文件}TFile.Rece();//替换文件,dest会备份在bak,source的内容到后sourece会被删除source:='c:\temp\t1.txt';dest:='c:\temp\t2.txt';bak:='c:\temp\t3.txt';TFile.Rece(source,dest,bak);{前两个文件必须存在}TFile.Rece(source,dest,bak,True);{忽略错误}buf:array[0..1023]ofByte;fs:TFileStream;FillChar(bufSizeOf(buf65);fs:=TFile.Create('c:\temp\test1.txt');fs.Write(buf,SizeOf(buf));fs:=TFile.Create('c:\temp\test2.txt',SizeOf(buf));fs.Write(buf,SizeOf(buf));buf:array[0..2]ofChar=('A','B',path:string;path:='c:\temp\test.dat'; fs:=TFile.OpenWrite(path);fs.Seek(0TSeekOrigin.soEnd把流指针移到尾部}fs.Write(buf,Length(buf)*SizeOf(Char));path:string;path:='c:\temp\test.dat'; fs:=TFile.OpenRead(path);path:string;path fs:=TFile.Open(path,//重载二:指定打开模式、操作权限;默认线程权限是fsNonefs:=TFile.Open(path,TFileMode,TFileAccess);fs:=TFile.Open(path,TFileMode,TFileAccess,TFileMode打开模式 创建新文件,如果文件已存在则将异常; 创建新文件,如果文件已存在则覆盖; 打开现有文件,如果该文件不存在则将异常;TFileMode.fmOpenOrCreate打开文件,如果文件不存在则建新文件; }TFileMode操作权限 }{TFileShare对其他线程的 TFileMode.fsReadWrite允许其他线程读写.}path:sw:path:=swTFile.CreateText(path)UTF8格式}path:sw:path:=swTFile.AppendText(path)UTF8格式}path:='c:\temp\test.txt';TFile.AppendAllText(pathNewString'TEncoding.UTF8可指定编返回path:sr:path:=srTFile.OpenText(pathUTF8格式}path:='c:\temp\test.txt';,TFile.WriteAllLines();//打开文本文件写入指定的字符串数组后关闭不管文件存path:arrTStringDynArrayTypes单元arr[0]:='AAA';arr[1]:=path:='c:\temp\test.txt';);{bs:TBytes;SetLength(bs,bs[0]:=bs[1]:=path:='c:\temp\test.txt';str:string;path:='c:\temp\test.txt';str:=TFile.ReadAllText(path);strTFile.ReadAllText(pathTEncoding.UTF8可指定编码格式path:arrTStringDynArrayTypes单元path:=arr:=arrTFile.ReadAllLines(pathTEncoding.UTF8)可指定编码格式}bs:TBytes;path:=bs:=TFile.ReadAllBytes(path);格式)}TFile.GetCreationTime(); Androidapi.JNI.Net,FMX.tform,FMX.Helpers.Android,Androidapi.JNIBridge,Androidapi.Helpers,Androidapi.JNI.ephony,FMX.PhoneDialer,Androidapi.JNI.Os{Publicdeclarations// procedurePhoneCall(phoneNumber:stringprocedureGetSN;//获取AndroidSIM卡串procedureSentSMS(phoneNumber,SMSstring:string);//直接没有任何提示的procedureSentSMSfromIntent(phoneNumberSMSstringstring调用系统程序发functionFetchSms:string;//收:);////状态请用phone.OnCallStateChanged//调用系统程序发uri:Intent://直接没有任何提示的j:=tjsmsmanager.Create;procedureTForm1.GetSN;//获取AndroidSIM卡串ifAssigned(ephonyServiceNative)then ephonyManager.getLine1Number取MSISDN号,大部分SIM卡中不会写入这个 ephonyManager.getSubscriberId取IMSI functionTForm1.FetchSmsstring;//uri:Jnet_Uri;address,,msgdatesent,protocol,msgread,msgstatus,msgtype,msgreplypathpresent,Subject,body,servicecenter,locked:string; x,idx,msgdateidx,msgdatesentidx,protocolidx,msgreadidx,msgstatusidx,msgtypeidx,msgreplypathpresentidx,subjectidx,bodyidx,servicecenteridx,lockedidx:integer;//cursor:=SharedActivity.getContentResolver.query(uri,nil,nil,nil,nil);cursor:=SharedActivity.)( //以上执行的语句是:SELECT*FROMsmsWHERE(type=1)AND(1=1)groupby(address)orderbydateascaddrex:=cursor.getColumnIndex(StringToJstring('address'));//idx:=cursor.getColumnIndex(StringToJstring(''));msgdateidx:=cursor.getColumnIndex(StringToJstring('date'));protocolidx:=cursor.getColumnIndex(StringToJstring('protocol'));msgreadidx:=cursor.getColumnIndex(StringToJstring('read'));msgstatusidx:=cursor.getColumnIndex(StringToJstring('status'));msgtypeidx:=cursor.getColumnIndex(StringToJstring('type'));msgreplypathpresentidx:=cursor.getColumnIndexbodyidx:=cursor.getColumnIndex(StringToJstring('body'));lockedidx:=cursor.getColumnIndex(StringToJstring('locked')); :=JStringToString(cursor.getString(idx));msgunixtimestampms:=cursor.getLong(msgdateidx);protocol:=JStringToString(cursor.getString(protocolidx));msgread:=JStringToString(cursor.getString(msgreadidx));msgstatus:=JStringToString(cursor.getString(msgstatusidx));msgtype:=JStringToString(cursor.getString(msgtypeidx));msgreplypathpresent:=JStringToStringbody:=JStringToString(cursor.getString(bodyidx));locked:=JStringToString(cursor.getString(lockedidx));号码:address+ :' +'protocol:'+protocol+'msgread:'++'msgstatus:'+msgstatus+'msgtype:'+msgtype+'Subject:'++'locked:'+locked内容: //Call_URI(TJIntent.JavaClass.ACTION_CALL,':10086'); ','直接没有任何提示的');//直接没有任何提示的发送短 ','调用系统程序发。');//调用系统程序发,短Call_URI(TJIntent.JavaClass.ACTION_SENDTO,'mai 调用系统程序发GetSN;//Label1.Text:='本IMEI:'+jstringtostring( ephonyManager.getDeviceId);//取IMEI; // uri:Intent:uri:=Label1.Text:='9打 打菜单project->options…选择userspermitions。SMSread资料性附录:Androidpermission权限大(打菜单project->options…选择userspermitions即可打开权限设置框。以下内容看看允许读写”properties”表在checkin数据库中,改值可以修改上传(Allowsread/writeaccesstothe“propertiestableinthecheckindatabase,tochangevaluesthatgetuploaded)允许一个程序Cell-ID或WiFi热点来获取粗略的位置(Allowsanapplicationtoaccesscoarse(e.g.,Cell-ID,WiFi)location)允许一个程序精确位置(如GPS)(Allowsanapplicationtoaccessfine(e.g.,GPS) 允许应用程序额外的位置提供命令(Allowsanapplicationtoaccessextralocationprovider允许程序创建模拟位置提供用于测试(Allowsanapplicationtocreatemocklocationprovidersfortesting)SurfaceFlinger(AllowsanapplicationtouseSurfaceFlinger’slowlevel允许程序Wi-Fi网络状态信息(AllowsapplicationstoaccessinformationaboutWi-Fi允许程序更新电池统计信息(Allowsanapplicationtoupdatethecollectedbattery允许程序广播一个提示消息在一个应用程序包已经移除后(Allowsanapplicationtobroadcastanotificationthatanapplicationpackagehasbeenremoved) 拨号不需通过拨号用户界面需要用户确认(AllowsanapplicationtoinitiateaphonecallwithoutgoingthroughtheDialeruserinterfacefortheusertoconfirmthecallbeingced.)applicationtocallanyphonenumber,includingemergencynumbers,withoutgoingthroughtheDialeruserinterfacefortheusertoc

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论