Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Cross-Platform-Entwicklung (https://www.delphipraxis.net/91-cross-platform-entwicklung/)
-   -   Delphi Android / BroadcastListener / Zebra Scanner / DataWedge (https://www.delphipraxis.net/214942-android-broadcastlistener-zebra-scanner-datawedge.html)

Gruber_Hans_12345 9. Apr 2024 09:17

Android / BroadcastListener / Zebra Scanner / DataWedge
 
Hallo ich versuche gerade in einer App den Intent von der DataWedge des ZEbra Scanners zu bekommen.

Dazu habe ich in meinem manifest
Code:
            <intent-filter>
            <action android:name="org.test.intent.barcode" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
Mein code in Delphi sieht so aus
Code:
type
  TDataWedgeDataEvent = procedure(Sender: TObject; const Data: string) of object;

  TDataWedgeBroadcastListener = class(TJavaLocal, JFMXBroadcastReceiverListener)
  private
    FReceiver: JBroadcastReceiver;
    FOnData: TDataWedgeDataEvent;
  public
    { JFMXBroadcastReceiverListener }
    procedure onReceive(context: JContext; intent: JIntent); cdecl;
  public
    constructor Create;
    destructor Destroy; override;
    property OnData: TDataWedgeDataEvent read FOnData write FOnData;
  end;

constructor TDataWedgeBroadcastListener.Create;
var
  LIntentFilter: JIntentFilter;
begin
  inherited;
  FReceiver := TJFMXBroadcastReceiver.JavaClass.init(Self);
  LIntentFilter := TJIntentFilter.JavaClass.init;
  LIntentFilter.addAction(StringToJString('org.test.intent.barcode'));
  //LIntentFilter.addCategory(StringToJString('android.intent.category.DEFAULT'));
  TAndroidHelper.Context.registerReceiver(FReceiver, LIntentFilter);
  frTest.meDebug.Lines.Add('INIT OK');
end;

destructor TDataWedgeBroadcastListener.Destroy;
begin
  TAndroidHelper.Context.unregisterReceiver(FReceiver);
  inherited;
end;

procedure TDataWedgeBroadcastListener.onReceive(context: JContext; intent: JIntent);
var
    data   : string;
begin
    frTest.meDebug.Lines.Add('onReceive');
    data   := JStringToString(intent.getStringExtra(StringToJString('com.symbol.datawedge.data_string')));
    frTest.meDebug.Lines.Add('onReceive : "'+data+'"');
    if (intent <> nil) and Assigned(FOnData) then
        FOnData(Self, data);
end;

var
    dw : TDataWedgeBroadcastListener;

procedure TfrTest.Button4Click(Sender: TObject);
begin
    dw := TDataWedgeBroadcastListener.Create;
    //
end;
Im Datawegde von ZEbra habe ich
Code:
Profile Enabled
Associated Apps: "com.embarcadero.firemonkey.FMXNativeActivity | com.embarcadero.test"
Barcode Input: Enabled
Keystroke Output: Disabled
Intent Output section:
  Intent action: org.test.intent.barcode
  Intent category: android.intent.category.DEFAULT (oder leer gelassen)
  Intent delivery: startActivity (bzw Broadcast intent)
  Component Information: [empty]
Hat da noch wer einen Tipp was da noch wo falsch sein könnte?
In das onReceive geht er nie rein


Alle Zeitangaben in WEZ +1. Es ist jetzt 01:04 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz