重置默认配置文件

DataWedge 7.4

RESET_DEFAULT_PROFILE

用于将默认配置文件重置为 Profile0。

函数原型

Intent i = new Intent(); i.setAction("com.symbol.datawedge.api.ACTION"); i.putExtra("com.symbol.datawedge.api.RESET_DEFAULT_PROFILE", "");

参数

ACTION [字符串]:"com.symbol.datawedge.api.ACTION"

EXTRA_DATA [字符串]:"com.symbol.datawedge.api.RESET_DEFAULT_PROFILE"

结果代码

如果应用程序包括 Intent 额外项 RECEIVE_RESULTCOMMAND_IDENTIFIER 以使应用程序能够使用 DataWedge 结果 Intent 机制获取结果,则 DataWedge 返回以下错误代码。请参阅以下示例

  • PROFILE_ALREADY_SET - FAILURE

有关更多信息,另请参阅结果代码指南

返回值

将错误和调试消息记录到可通过 logcat 命令查看和过滤的 Android 日志记录系统。从 ADB Shell 使用 logcat 查看日志消息:

$ adb logcat -s DWAPI

记录无效操作、参数和故障(例如,配置文件未找到或已与某个应用程序相关联)的错误消息。

示例代码

::javascript // define action string String action = "com.symbol.datawedge.api.ACTION"; String extraData = "com.symbol.datawedge.api.RESET_DEFAULT_PROFILE"; public void onResume() { // create the intent Intent i = new Intent(); // set the action to perform i.setAction(action); i.putExtra(extraData, ""); // empty since a name is not required this.sendBroadcast; }

设置/获取结果代码

命令和配置 Intent 参数决定是否发送结果代码(默认情况下处于禁用状态)。使用 SEND_RESULT 时,COMMAND_IDENTIFIER 用于将结果代码与起源 Intent 进行匹配。这些参数的示例用法如下所示。

注意:修改此通用代码以与要使用的 API 匹配

// send the intent Intent i = new Intent(); i.setAction(ACTION); i.putExtra("com.symbol.datawedge.api.CREATE_PROFILE", "Profile1"); // request and identify the result code i.putExtra("SEND_RESULT","true"); i.putExtra("COMMAND_IDENTIFIER","123456789"); this.sendBroadcast(i); // register to receive the result public void onReceive(Context context, Intent intent){ String command = intent.getStringExtra("COMMAND"); String commandidentifier = intent.getStringExtra("COMMAND_IDENTIFIER"); String result = intent.getStringExtra("RESULT"); Bundle bundle = new Bundle(); String resultInfo = ""; if(intent.hasExtra("RESULT_INFO")){ bundle = intent.getBundleExtra("RESULT_INFO"); Set<String> keys = bundle.keySet(); for (String key: keys) { resultInfo += key + ": "+bundle.getString(key) + "\n"; } } String text = "Command: "+command+"\n" + "Result: " +result+"\n" + "Result Info: " +resultInfo + "\n" + "CID:"+commandidentifier; Toast.makeText(context, text, Toast.LENGTH_LONG).show(); };

生成和接收结果代码

命令和配置 Intent 参数决定是否发送结果代码(默认情况下处于禁用状态)。使用 SEND_RESULT 时,COMMAND_IDENTIFIER 用于将结果代码与起源 Intent 进行匹配。这些参数的示例用法如下所示。

注意:修改此通用代码以与要使用的 API 匹配

// send the intent Intent i = new Intent(); i.setAction(ACTION); i.putExtra("com.symbol.datawedge.api.CREATE_PROFILE", "Profile1"); // request and identify the result code i.putExtra("SEND_RESULT","true"); i.putExtra("COMMAND_IDENTIFIER","123456789"); this.sendBroadcast(i); // register to receive the result public void onReceive(Context context, Intent intent){ String command = intent.getStringExtra("COMMAND"); String commandidentifier = intent.getStringExtra("COMMAND_IDENTIFIER"); String result = intent.getStringExtra("RESULT"); Bundle bundle = new Bundle(); String resultInfo = ""; if(intent.hasExtra("RESULT_INFO")){ bundle = intent.getBundleExtra("RESULT_INFO"); Set<String> keys = bundle.keySet(); for (String key: keys) { resultInfo += key + ": "+bundle.getString(key) + "\n"; } } String text = "Command: "+command+"\n" + "Result: " +result+"\n" + "Result Info: " +resultInfo + "\n" + "CID:"+commandidentifier; Toast.makeText(context, text, Toast.LENGTH_LONG).show(); };

注释

(无)


另请参阅

Zebra 支持中心 | 集成商指南、产品手册、软件下载和支持

LaunchPad | Zebra 开发人员社区

Intent | Android 开发人员

Intent 和 Intent 过滤器 | Android 开发人员

Android Intent | 教程