Delphi XE inside Sharedactivitycontext hint error

Source: Internet
Author: User

Unit with Crooked Nuts

//--------------------

Unit Android.JNI.Toast;

Java Bridge class imported by hand by Brian Long (http://blong.com)
Interface

{$IFDEF ANDROID}

Uses
Androidapi.jnibridge,
Androidapi.JNI.JavaTypes,
Androidapi.JNI.GraphicsContentViewText;
{$ENDIF}
{$IFDEF ANDROID}

Type
Ttoastlength = (longtoast, shorttoast);

Jtoast = interface;

Jtoastclass = Interface (jobjectclass)
[' {69e2d233-b9d3-4f3e-b882-474c8e1d50e9} ']
{property methods}
function _getlength_long:integer; Cdecl
function _getlength_short:integer; cdecl;
{Methods}
function init (context:jcontext): Jtoast; cdecl; overload;
function Maketext (context:jcontext; text:jcharsequence; duration:integer)
: jtoast; cdecl;
{Properties}
Property Length_long:integer Read _getlength_long;
Property Length_short:integer Read _getlength_short;
End;

[Javasignature (' Android/widget/toast ')]
Jtoast = Interface (jobject)
[' {fd81cc32-bfbc-4838-8893-9dd01de47b00} ']
{Methods}
procedure Cancel; Cdecl
function Getduration:integer; Cdecl
function Getgravity:integer; Cdecl
function Gethorizontalmargin:single; Cdecl
function Getverticalmargin:single; Cdecl
function Getview:jview; Cdecl
function Getxoffset:integer; Cdecl
function Getyoffset:integer; Cdecl
Procedure Setduration (Value:integer); Cdecl
Procedure setgravity (Gravity, Xoffset, Yoffset:integer); Cdecl
Procedure SetMargin (HorizontalMargin, Verticalmargin:single); Cdecl
Procedure SetText (s:jcharsequence); Cdecl
Procedure Setview (View:jview); Cdecl
Procedure Show; Cdecl
End

Tjtoast = Class (Tjavagenericimport<jtoastclass, Jtoast>)
End

Procedure Toast (const msg:string; duration:ttoastlength = shorttoast);

{$ENDIF}

Implementation

{$IFDEF ANDROID}

Uses
FMX. Helpers.android,
androidapi.helpers;//Plus, otherwise sharedactivitycontext prompt error,

Procedure Toast (const msg:string; duration:ttoastlength);
Var
Toastlength:integer;
Begin
If Duration = Shorttoast Then
Toastlength: = TJToast.JavaClass.LENGTH_SHORT
Else
Toastlength: = TJToast.JavaClass.LENGTH_LONG;
Callinuithread (
Procedure
Begin
TJToast.JavaClass.makeText (Sharedactivitycontext, Strtojcharsequence (MSG),
Toastlength). Show
End);
End
{$ENDIF}

End.

//-------------------

On the page used:


Uses
Android.JNI.Toast,

Procedure Tform2.formkeyup (Sender:tobject; var Key:word; var Keychar:char;
Shift:tshiftstate);
Begin
if (key = Vkhardwareback) or (key = Vkescape) Then
Begin
If Isfirstback Then
Begin
Isfirstback: = False;
Key: = 0;
timer1.enabled: = True;
Toast (' Press again to exit ', shorttoast);
Toast (' Press again to exit ', shorttoast);
End
Else
Begin
End
End
End

On the form (TFORM2) onkeyup-->formkeyup

Delphi XE inside Sharedactivitycontext hint error

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.