Trigger scanning on a Zebra TC25 with an Android Delphi application

  android, barcode, delphi, zebra

I’m developing an Android application with Embarcadero RAD Studio 10.2 to deploy on a Zebra TC25.
I’m trying to activate the scanner by clicking a button on a screen. (Like pressing the yellow buttons on the sides of the pad)

procedure TMainForm.btnScanClick(Sender: TObject);
var
  Intent: JIntent; //Declares the intent object
begin
  try
    Intent := TJIntent.Create;
    Intent.setType(StringToJString('text/pas'));
    Intent.setAction(StringToJString('com.symbol.datawedge.api.ACTION')); 
    Intent.putExtra(StringToJString('com.symbol.datawedge.api.SOFT_SCAN_TRIGGER'), StringtoJString('START_SCANNING'));
    if MainActivity.getPackageManager.queryIntentActivities(Intent, TJPackageManager.JavaClass.MATCH_DEFAULT_ONLY).size > 0 then
      MainActivity.startActivity(Intent) //Calls startActivity() to send the intent to the system.
    else
      mmLogs.Lines.Add('Erreur: '+DateTimeToStr(now)+' - Receiver not found');
  except
    on E:Exception do
      mmLogs.Lines.Add('Erreur: '+DateTimeToStr(now)+' - btnScanClick - '+E.Message);
  end;
end;

Here is the content of the AndroidManifest for the Activity part.

<activity android:name="com.embarcadero.firemonkey.FMXNativeActivity"
        android:label="%activityLabel%"
        android:configChanges="orientation|keyboard|keyboardHidden|screenSize"
        android:launchMode="singleTask">
    <!-- Tell NativeActivity the name of our .so -->
    <meta-data android:name="android.app.lib_name"
        android:value="%libNameValue%" />
    <intent-filter>  
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter> 
    <intent-filter>
        <action android:name="com.wa.ZebraDW.ACTION" />
        <category android:name="android.intent.category.DEFAULT" />
    </intent-filter> 
</activity>

I took inspiration from that:

Nothing happens. :/

Source: Android Questions

One Reply to “Trigger scanning on a Zebra TC25 with an Android Delphi application”

LEAVE A COMMENT