Reputation: 23
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:
I always get the error message about "Receiver not found" in the memo. The device doesn't start scanning.
Upvotes: 2
Views: 1460
Reputation: 164
This works fine with Delphi 10.3 and the Zebra TC56/TC55 devices tested. The AndroidManifest remains untouched without any aditional entry needed.
procedure TForm1.btnTriggerScanClick(Sender: TObject);
var Intent: JIntent;
begin
Intent := TJIntent.JavaClass.init;
Intent.setAction(StringToJString('com.symbol.datawedge.api.ACTION_SOFTSCANTRIGGER'));
Intent.putExtra(StringToJString('com.symbol.datawedge.api.EXTRA_PARAMETER'), StringToJString('START_SCANNING'));
TAndroidHelper.Activity.sendBroadcast(Intent);
end;
Upvotes: 1