プロファイルの作成

DataWedge 11.0

CREATE_PROFILE

デバイス上に新しい DataWedge プロファイルを作成するために使用します。同じ名前のプロファイルがデバイスにすでに存在する場合、インテントは失敗します。プロファイルを作成し、その設定パラメータを構成するには、「SET_CONFIG」を参照してください。プロファイル名は一意で、英数字を使用し、プロファイルのインポート/エクスポート問題を回避するために短くすることが推奨されています。

関数プロトタイプ


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

パラメータ

ACTION [String]: com.symbol.datawedge.api.ACTION

EXTRA_DATA [String]: com.symbol.datawedge.api.CREATE_PROFILE

String <値>: 作成するプロファイルの名前

結果コード

DataWedge は、アプリにインテント エクストラ (SEND_RESULT および COMMAND_IDENTIFIER) が含まれている場合、次のエラー コードを返し、DataWedge の結果インテント メカニズムを使用してアプリで結果を取得できるようにします。以下のを参照してください。

  • PROFILE_ALREADY_EXIST - エラー
  • PROFILE_NAME_EMPTY - エラー

詳細については、結果コード ガイドも参照してください。

コード例

    
    private void createProfile() {
    Intent i = new Intent();
    i.setAction("com.symbol.datawedge.api.ACTION");
    i.putExtra("com.symbol.datawedge.api.CREATE_PROFILE", profileName);
    this.sendBroadcast(i);
}

結果の生成および受信

コマンドおよび構成インテント パラメータは、結果コードを送信するかどうかを決定します (デフォルトでは無効)。SEND_RESULT を使用する場合は、結果コードと元のインテントを照合するために、COMMAND_IDENTIFIER を使用します。こうしたパラメータの使用方法のサンプルを以下に示します。

注: 使用する 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();

    };

結果コードの設定/取得

コマンドおよび構成インテント パラメータは、結果コードを送信するかどうかを決定します (デフォルトでは無効)。SEND_RESULT を使用する場合は、結果コードと元のインテントを照合するために、COMMAND_IDENTIFIER を使用します。こうしたパラメータの使用方法のサンプルを以下に示します。

注: 使用する 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 Support Central | インテグレータ ガイド、製品マニュアル、ソフトウェア ダウンロードおよびサポート

LaunchPad | Zebra 開発者コミュニティ

インテント | Android 開発者

インテントおよびインテント フィルタ | Android 開発者

Android インテント | チュートリアル