@Override
  public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK) {
      ReleasePalletOccupy(); // 监控/拦截/屏蔽返回键
      return true;
    } else if (keyCode == KeyEvent.KEYCODE_MENU) {
      if (sacnnerstatus == 0) {

        app.startDecode();
        sacnnerstatus = 1;
        return true;
      } else {
        app.stopDecode();
        sacnnerstatus = 0;
        return true;
      }
    }
    return super.onKeyDown(keyCode, event);
  }
  @Override
  protected void onResume() {
    // TODO Auto-generated method stub
    super.onResume();
    TextView Textbottom = (TextView) this.findViewById(R.id.maintext);
    if (app.getBizdate() == null) {

      Textbottom.setText(
          AutoInvertExecActivity.this.getResources().getString(R.string.notselectbizdate));
      Textbottom.setTextColor(this.getResources().getColor(R.color.red));
    } else {
      Textbottom.setText(
          AutoInvertExecActivity.this.getResources().getString(R.string.bizdate)
              + app.getBizdate()
              + "  "
              + AutoInvertExecActivity.this.getResources().getString(R.string.bizwork)
              + app.getWork()
              + "  "
              + AutoInvertExecActivity.this.getResources().getString(R.string.bizgroup)
              + app.getGroup());
      Textbottom.setTextColor(this.getResources().getColor(R.color.white));
    }
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.autoinvertexec);

    listView = (RadListView) findViewById(R.id.storeintyrelv);
    textconfrim = (TextView) findViewById(R.id.textconfirm);
    textstart = (TextView) findViewById(R.id.textstart);
    textback = (TextView) findViewById(R.id.textback);
    textfromlgpos = (TextView) findViewById(R.id.textfromlgpos);
    textmatdesc = (TextView) findViewById(R.id.textmatdesc);
    textpallet = (TextView) findViewById(R.id.textpallet);
    textmat = (TextView) findViewById(R.id.textmat);
    textbindquantity = (TextView) findViewById(R.id.textbindquantity);
    tolgpos = (TextView) findViewById(R.id.texttolgpos);
    todoList = new ArrayList<String>();
    this.todoAdapter = new ListItemsAdapter(todoList, R.layout.list_view_reorder_todo_layout);
    this.listView.setAdapter(this.todoAdapter);
    app = (ExamplesApplicationContext) this.getApplicationContext();
    app.addActivity(this);
    /*
     * if (app.getUserid() == null) {
     *
     * AlertDialog.Builder builder = new AlertDialog.Builder(this);
     * builder.setMessage("请登录") .setCancelable(false)
     * .setPositiveButton(getResources().getString(R.string.OK), new
     * DialogInterface.OnClickListener() { public void
     * onClick(DialogInterface dialog, int id) { Intent intent = new
     * Intent(AutoInvertExecActivity.this, LoginActivity.class);
     * AutoInvertExecActivity.this.startActivity(intent);
     * AutoInvertExecActivity.this.finish(); } }); AlertDialog alert =
     * builder.create(); alert.show();
     *
     * }
     */
    SharedPreferences sharedPreferences = getSharedPreferences("userinfo", Activity.MODE_PRIVATE);
    Forklift = sharedPreferences.getString("forkliftnum", "");

    sp = new SoundPlay(AutoInvertExecActivity.this);
    companynum = getIntent().getStringExtra("company");
    fromlgpos = getIntent().getStringExtra("fromlgpos");
    textfromlgpos.setText(fromlgpos);

    palletnum = getIntent().getStringExtra("palletnum");
    textpallet.setText(palletnum);
    bindmat = getIntent().getStringExtra("bindmat");
    textmat.setText(bindmat);
    bindcount = getIntent().getStringExtra("bindquantity");
    textbindquantity.setText(bindcount);

    bindmatdesc = getIntent().getStringExtra("bindmatdesc");
    textmatdesc.setText(bindmatdesc);
    NotificationManager mManager =
        (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    mManager.cancel(0);

    QryAutoLgpos();
    textstart.setOnClickListener(
        new android.view.View.OnClickListener() {

          @Override
          public void onClick(android.view.View v) {

            if (textpallet.getText().length() <= 0) {

              AutoInvertExecActivity.this.finish();
            }

            Builder dialog = new AlertDialog.Builder(AutoInvertExecActivity.this);

            dialog.setTitle("Mark Exception ?");
            LayoutInflater inflater =
                (LayoutInflater)
                    AutoInvertExecActivity.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            LinearLayout layout = (LinearLayout) inflater.inflate(R.layout.dialogview, null);
            dialog.setView(layout);
            final EditText markedit = (EditText) layout.findViewById(R.id.dialogedit);
            dialog.setPositiveButton(
                AutoInvertExecActivity.this.getResources().getString(R.string.OK),
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int which) {
                    mark = markedit.getText().toString();
                    oldlgpos = tolgposnum;
                    tolgposnum = "";
                    execExceptionAutoInvert();
                  }
                });

            dialog.setNegativeButton(
                AutoInvertExecActivity.this.getResources().getString(R.string.cancel),
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int which) {}
                });
            dialog.show();
          }
        });

    textback.setOnClickListener(
        new android.view.View.OnClickListener() {

          @Override
          public void onClick(View v) {
            ReleasePalletOccupy();
          }
        });
    textconfrim.setOnClickListener(
        new android.view.View.OnClickListener() {

          @Override
          public void onClick(View v) {
            execAutoInvert();
          }
        });
  }