Quantcast
Channel: Embarcadero Community - Embarcadero Community
Viewing all articles
Browse latest Browse all 1888

Android services and TLocationSensor

$
0
0
 
Hi,
to include System.Sensors (TLocationSensor) or FMX.Types (TTimer) in Uses clause in service, this is not created.
the example given in Delphi (BeaconServiceDemo) works.
but if you change Uses of BeaconServiceUnit.pas for:
uses System.SysUtils, System.Classes, System.Android.Service, AndroidApi.JNI.GraphicsContentViewText, Androidapi.JNI.Os, System.Beacon, System.Notification, System.Beacon.Components, System.Sensors;
does not work. The service is not created.
to test, changed the following routine:
implementation

{%CLASSGROUP 'FMX.Controls.TControl'}

{$R *.dfm}

uses
Androidapi.JNI.App,
Androidapi.JNIBridge,
AndroidApi.JNI.Media;
function TBeaconServiceDM.AndroidServiceStartCommand(const Sender: TObject; const Intent: JIntent; Flags,
StartId: Integer): Integer;

procedure Sound(ADuration: Integer);
var
Volume: Integer;
StreamType: Integer;
ToneType: Integer;
ToneGenerator: JToneGenerator;
begin
Volume := TJToneGenerator.JavaClass.MAX_VOLUME;
StreamType := TJAudioManager.JavaClass.STREAM_ALARM;
ToneType := TJToneGenerator.JavaClass.TONE_DTMF_0;
ToneGenerator := TJToneGenerator.JavaClass.init(StreamType, Volume);
ToneGenerator.startTone(ToneType, ADuration);
end;

begin
sound(100); // with system.sensors, not play the sound and message "The BeaconServiceApp stopped"[/b]
Beacon1.Enabled := True;
Result := TJService.JavaClass.START_STICKY;
end;

my configuration:
Delphi 10 Seattle Update 1
android 4.4.4
Does anyone know what can it be?
 
 
 

 


Viewing all articles
Browse latest Browse all 1888

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>