First of all, I want to thank you about article you shared about IntentWedge via flutter. That is incredibly fast even with the longest barcodes. I have only one struggle. When Intent wedge feature is not enabled by user we can not use the IntentWedge. So I needed to check whether IntentWedge feature is enabled or not at the beginning of the app and if it is not enabled, I want to redirect the user to related settings and open it. Can you explain to me how to achieve this one?
I’ll see if there is anything I can answer, if I miss something Donato can help fill in the gaps.
You can use our SDK to do all of this, no need to send the user to a page in the settings.
You will want to check if the normal keyboard wedge is enabled and disable that so that the barcode data is not typed on screen.
Then check if the intent wedge is disabled and enable it if needed.
Also, here is a link to some example apps written in Kotlin and Java.
There is a specific example app, DecodeConfig, which covers adjusting the decode configuration.
The example doesn’t cover adjusting the wedge but similar settings.
Drew Hugentobler L3 Mobile Computer Specialist Support Engineer
Thanks for your quick replies @Donato_Cataldo and @Drew_Hugentobler. My aim was if you not manually open intent wedge feature from android settings, It is not working(as it should be). Just to be sure that each time I open my app I want to check that intent wedge feature is enabled programmatically or not . Cause somehow, it can be disabled by end user and they may complain about it is not working :D. I tried many options(SDK documentations included.) and could not find any solution for this. My approach to this topic might be wrong. What do you say about this?
It is hard to know for sure what could be causing your issue.
This is the first report we have heard of this issue.
One way we could assist you is to review your code.
The easiest way would be for you to edit the decodeConfig example we provide.
Add the code needed to accomplish your goal and verify it is not working.
Then send us that code and we can see if there is something you are missing or if it is a defect in our SDK.
Drew Hugentobler L3 Mobile Computer Specialist Engineer
I’m actually trying to say that I want to check intent wedge is enabled or not in android OS settings.I’m sharing the photo of it. In my flutter app, I want to check exactly this setting whether it is enabled or disabled. If This setting is disabled somehow, I want to let user knows that is actually intent wedge feature is disabled by settings. I want to show some sort of pop up and navigate the user to related settings from the app. Hope I can be more clear.
Thank you for your patience while we assist you with this issue.
I fully understand what you are trying to do.
I’m actually trying to say that I want to check intent wedge is enabled or not in android OS settings.
The intent wedge is disabled by default, there are several things that can revert this setting to default. Ideally you would fix whatever is disabling this setting. But you can do what you are describing.
I’m sharing the photo of it. In my flutter app, I want to check exactly this setting whether it is enabled or disabled.
Check the setting enable intent wedge, I understand.
If This setting is disabled somehow, I want to let user knows that is actually intent wedge feature is disabled by settings.
You can check and change this setting programmatically. The user does not need to know if it is on or not.
I want to show some sort of pop up and navigate the user to related settings from the app. Hope I can be more clear.
You could do this, but we do not offer a way to send someone to a particular part of our settings. We don’t offer this feature because we allow you the developer to change the settings without user input.
I added Datalogic memor SDK to build.gradle and it is working fine in debug mode at flutter. But when I try in release mode it says asynchronous suspension error. Do you have any idea that what possibly cause this problem? buildGradle logs
I tried couple things but no luck. It is working in debug mode but not working in release mode. I sharing my build Gradle files and my mainActivity codes. Hope You can understand what I’m missing
BuildGradle(app level)
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 33
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = '1.8'
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.mpsmobile.assistant"
minSdkVersion 21
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'com.github.datalogic:datalogic-android-sdk:1.32'
}
package com.mpsmobile.assistant
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.widget.Toast
import androidx.annotation.NonNull
import com.datalogic.decode.BarcodeManager
import com.datalogic.decode.configuration.ScannerProperties
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugin.common.EventChannel
import io.flutter.plugin.common.MethodCall
import io.flutter.plugin.common.MethodChannel
class MainActivity: FlutterActivity() {
private val ACTION_BROADCAST_RECEIVER = "com.datalogic.decodewedge.decode_action"
private val CATEGORY_BROADCAST_RECEIVER = "com.datalogic.decodewedge.decode_category"
private val EXTRA_DATA_STRING = "com.datalogic.decode.intentwedge.barcode_string"
private val EVENT_CHANNEL_BARCODE_INTENT = "app.channel.event.barcode_intent"
private var receiver: BroadcastReceiver? = null
private var filter: IntentFilter? = null
private val CHANNEL = "datalogic/configuration"
override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
super.configureFlutterEngine(flutterEngine)
EventChannel(flutterEngine.dartExecutor.binaryMessenger, EVENT_CHANNEL_BARCODE_INTENT).setStreamHandler(
object : EventChannel.StreamHandler {
override fun onListen(args: Any?, events: EventChannel.EventSink) {
receiver = BarcodeIntentReceiver(events)
filter = IntentFilter()
filter!!.addAction(ACTION_BROADCAST_RECEIVER)
filter!!.addCategory(CATEGORY_BROADCAST_RECEIVER)
registerReceiver(receiver, filter)
}
override fun onCancel(args: Any?) {
//Log.i(LOGTAG, "EVENT_CHANNEL_BARCODE_INTENT has been canceled")
}
}
)
MethodChannel(
flutterEngine.dartExecutor.binaryMessenger,
CHANNEL
).setMethodCallHandler { call, result ->
when {
call.method.equals("enableIntentWedge") -> {
enableIntentWedge(call, result)
}
}
}
}
private fun BarcodeIntentReceiver(events: EventChannel.EventSink?) : BroadcastReceiver? {
return object : BroadcastReceiver() {
override fun onReceive(context: Context, wedgeIntent: Intent) {
//Log.i(LOGTAG, "received" + wedgeIntent.action)
val action = wedgeIntent.action
if (action == ACTION_BROADCAST_RECEIVER) {
events?.success(wedgeIntent.getStringExtra(EXTRA_DATA_STRING))
//Log.i(LOGTAG, "Decoding Broadcast Received")
}
}
}
}
private fun enableIntentWedge(call: MethodCall, result :MethodChannel.Result){
var managerx: BarcodeManager? = null
var configurationx: ScannerProperties? = null
var alreadyEnabled=false;
var isEnabled= call.arguments<Boolean>()?:false;
println(isEnabled)
// Create a BarcodeManager.
managerx = BarcodeManager()
// Pass it to ScannerProperties class.w
// ScannerProperties cannot be instantiated directly, instead call edit.
configurationx = ScannerProperties.edit(managerx)
alreadyEnabled= configurationx.intentWedge.enable.get()
println("AlreadyEnabled: $alreadyEnabled")
// Now we can change some Scanner/Device configuration parameters.
// These values are not applied, as long as the store method is not called.
// if keyboard wedge is enabled, intent wedge should be disabled.
if(!alreadyEnabled) {
configurationx!!.keyboardWedge.enable.set(isEnabled?.not() ?: false)
configurationx!!.intentWedge.enable.set(isEnabled)
// Change the IntentWedge action and category to specific ones.
configurationx!!.intentWedge.action.set(ACTION_BROADCAST_RECEIVER)
configurationx!!.intentWedge.category.set(CATEGORY_BROADCAST_RECEIVER)
// Now we are ready to store our settings changes.
// Second parameter set to true saves configuration in a permanent way.
// After boot, settings will be still valid.
configurationx!!.store(managerx, true)
alreadyEnabled= configurationx.intentWedge.enable.get()
if(alreadyEnabled){
Toast.makeText(applicationContext,"Intent Wedge feature is enabled" ,Toast.LENGTH_SHORT)
}
else {
Toast.makeText(applicationContext,"Keyboard Wedge feature is enabled" ,Toast.LENGTH_SHORT)
}
}
}
}
is it possible for you to share us the whole Project with the source code so we can do some compilation tests?
I suggest you fill out the form available at this link to get in touch with Technical Support and share your Project.
Donato Cataldo L3 Mobile Computer Support Engineer
I can not share entire project with you due to Company privacy rules. I already did a template project and reproduced the error again. I will share with techTeam. Thanks for your help.