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.
question from:
https://stackoverflow.com/questions/66061725/trigger-scanning-on-a-zebra-tc25-with-an-android-delphi-application 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…