Problem phenomenon: Found on the Foreigner's website, the generated app, after running, access to the service error. I wonder who the great God can help to see where the code goes wrong. Please, kneel!
1 UnitUnit1;2 3 Interface4 5 uses6 system.sysutils, System.types, System.uitypes, system.classes, System.variants,7 FMX. Types, FMX. Controls, FMX. Forms, FMX. Graphics, FMX. Dialogs,8 FMX. Controls.presentation, Fmx.stdctrls,9Androidapi.helpers,//need to introduceTenAndroidAPI.jni.OS,//need to introduce OneAndroidapi.jnibridge,// A Androidapi.JNI.GraphicsContentViewText, - Androidapi.JNI.JavaTypes, -FMX. helpers.android;// the - type -TForm1 =class(Tform) - Button1:tbutton; + procedureButton1Click (sender:tobject); - Private + {Private Declarations} A Public at {Public Declarations} - End; - type -Jconsumerirmanager_carrierfrequencyrange =Interface; - -Jconsumerirmanager_carrierfrequencyrangeclass =Interface(Jobjectclass) in['{191a7f08-b93b-40d4-9b6e-3d908b37578e}'] - {class} functionInit (min, max:integer): Jconsumerirmanager_carrierfrequencyrange;cdecl; to End; + -[Javasignature ('Android/hardware/consumerirmanager$carrierfrequencyrange')] theJconsumerirmanager_carrierfrequencyrange =Interface(Jobject) *['{5ac0c73d-9da2-49b0-a072-55ea03fe3b78}'] $ functionGetmaxfrequency:integer;cdecl;Panax Notoginseng functionGetminfrequency:integer;cdecl; - End; theTjconsumerirmanager_carrierfrequencyrange =class(Tjavagenericimport<jconsumerirmanager_carrierfrequencyrangeclass, Jconsumerirmanager_carrierfrequencyrange >)End; + AJconsumerirmanagerclass =Interface(Jobjectclass) the['{c8ab7eea-046f-429c-8585-ef69ebb53718}'] + End; - $[Javasignature ('Android/hardware/consumerirmanager')] $Jconsumerirmanager =Interface(Jobject) -['{FF469731-5B57-46AB-9C83-4FB51CA6F2BA}'] - functiongetcarrierfrequencies:tjavaarray<jconsumerirmanager_carrierfrequencyrange>;cdecl; the functionHasiremitter:boolean;cdecl; - procedureTransmit (carrierfrequency:integer; pattern:tjavaarray<integer>);cdecl;Wuyi End; theTjconsumerirmanager =class(Tjavagenericimport<jconsumerirmanagerclass, jconsumerirmanager>)End; - Wu - var About Form1:tform1; $ - Implementation - - {$R *.FMX} A functionMakejavaintarray (arr:Array ofInteger): tjavaarray<integer>; + var the I:integer; - begin $Result: = Tjavaarray<integer>.Create(Length (arr)); the forI: = Low (arr) toHigh (ARR) Do theResult.items[i]: =Arr[i]; the End; the - in procedureTform1.button1click (sender:tobject); the var the Mcir:jconsumerirmanager; AboutMranges:tjavaarray<jconsumerirmanager_carrierfrequencyrange>; the Mrange:jconsumerirmanager_carrierfrequencyrange; the I, Desiredfrequency:integer; the Hasdesiredfrequency:boolean; + begin -MCIR: =Tjconsumerirmanager.wrap ((Sharedactivitycontext.getsystemservice (TJContext.JavaClass.CONSUMER_IR_SERVICE) the asilocalobject). Getobjectid);Bayi ifMcir.hasiremitter Then the begin the //Use Mcir as needed ... - -Desiredfrequency: =3800; theHasdesiredfrequency: =False; the theMranges: =mcir.getcarrierfrequencies; the forI: =0 tomranges.length-1 Do - begin theMrange: =Mranges.items[i]; the if(Desiredfrequency >= mrange.getminfrequency) and(Desiredfrequency <= mrange.getmaxfrequency) Then the begin94Hasdesiredfrequency: =True; the Break ; the End; the End;98 About ifHasdesiredfrequency Then -Mcir.transmit (Desiredfrequency, Makejavaintarray ([8950,4350,650, -, -, -,550, -,550,550, -, -,550,550, -,550, -, -,550,1650, -, the,650, the,550,1700, -, the, -, the, -,1650, -, the,650, the,550,1650,650, the, -,550,550,550,550,550,550,550, -, -, -,550,550,550,550,550,550,1650,650, the, -, the, -,1650, -, the, -]));//The pattern values here101 End;102 End;103 104 End.
View Code
Android Instance-infrared operation (xe10.2+ Xiaomi 5)