Как программно настроить профиль Zebra TC21 Datawedge в приложении Android Kotlin?Android

Форум для тех, кто программирует под Android
Ответить
Anonymous
 Как программно настроить профиль Zebra TC21 Datawedge в приложении Android Kotlin?

Сообщение Anonymous »

Я разрабатываю приложение инвентаризации Android на Kotlin для устройств Zebra TC21 и хочу настроить профиль Datawedge программным способом. Мне нужно сканировать qr-коды с помощью встроенного сканера и RFID-метки с помощью Zebra RFD4031. Я хотел бы, чтобы отсканированные данные передавались посредством «Намеренного вывода» в режиме широковещания. Я также хочу, чтобы «вывод ключа» был отключен.
Я попробовал с помощью этого кода:

Код: Выделить всё

class DatawedgeConfig {
val baseConfig = createBaseConfig()

fun initialize(context: Context) {
try {
createProfile(context)
configureProfile(context)
configureInput(context)
configureOutput(context)
Log.d("DatawedgeConfig", "DataWedge initialized successfully")
} catch (e: Exception) {
Log.e("DatawedgeConfig", "Error initializing DataWedge", e)
}
}

private fun createBaseConfig(): Bundle {
return Bundle().apply {
putString("PROFILE_NAME", DATAWEDGE_PROFILE_NAME)
putString("PROFILE_ENABLED", "true")
putString("CONFIG_MODE", "UPDATE")
}
}

fun createProfile(context: Context) {
val intent = Intent()
intent.action = "com.symbol.datawedge.api.ACTION"
intent.putExtra("com.symbol.datawedge.api.CREATE_PROFILE", DATAWEDGE_PROFILE_NAME)
try {
context.sendBroadcast(intent)
Log.d("DatawedgeConfig", "Profile created successfully")
} catch (e: Exception) {
Log.e("DatawedgeConfig", "Error creating profile", e)
}
}

fun configureProfile(context: Context) {
val intent = Intent()
intent.action = "com.symbol.datawedge.api.ACTION"
intent.putExtra("com.symbol.datawedge.api.SET_CONFIG", Bundle().apply {
baseConfig.putParcelableArray("APP_LIST", arrayOf(Bundle().apply {
putString("PACKAGE_NAME", context.packageName)
putStringArray("ACTIVITY_LIST", arrayOf("*"))
}))
})

Log.d("DataWedgeConfig", "Configuring profile: $baseConfig")

try {
context.sendBroadcast(intent)
Log.d("DatawedgeConfig", "Profile configured successfully (PACKAGE_NAME : ${context.packageName})")
} catch (e: Exception) {
Log.e("DatawedgeConfig", "Error configuring profile", e)
}
}

fun configureInput(context: Context) {
val intent = Intent()
intent.action = "com.symbol.datawedge.api.ACTION"
intent.putExtra("com.symbol.datawedge.api.SET_CONFIG", Bundle().apply {
baseConfig.putParcelableArray("PLUGIN_CONFIG", arrayOf(Bundle().apply {
putString("PLUGIN_NAME", "BARCODE")
putString("RESET_CONFIG", "true")
putBundle("PARAM_LIST", Bundle().apply {
putString("scanner_selection", "auto")
putString("decoder_rfid", "true")
putString("decoder_qr_code", "true")
})
}))
})
try {
context.sendBroadcast(intent)
Log.d("DatawedgeConfig", "Input configured successfully")
} catch (e: Exception) {
Log.e("DatawedgeConfig", "Error configuring input", e)
}
}

fun configureOutput(context: Context) {
val intent = Intent()
intent.action = "com.symbol.datawedge.api.ACTION"
intent.putExtra("com.symbol.datawedge.api.SET_CONFIG", Bundle().apply {
baseConfig.putParcelableArray("PLUGIN_CONFIG", arrayOf(Bundle().apply {
putString("PLUGIN_NAME", "INTENT")
putString("RESET_CONFIG", "true")
putBundle("PARAM_LIST", Bundle().apply {
putString("intent_output_enabled", "true")
putString("intent_action", DATAWEDGE_ACTION)
putString("intent_delivery", "2")
})
}))
})
try {
context.sendBroadcast(intent)
Log.d("DatawedgeConfig", "Output configured successfully")
} catch (e:  Exception) {
Log.e("DatawedgeConfig", "Error configuring output", e)
}
}
}
Профиль фактически создается, если он не существует, но ни один из параметров пакета «SET_CONFIG» не применяется. Таким образом, мое приложение не связано с созданным профилем, а вывод намерений не включен и не настроен с заданными значениями.
Я не понимаю, почему.


Подробнее здесь: https://stackoverflow.com/questions/792 ... android-ko
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Android»