Example usage for org.apache.cordova.plugin HXiMateDeviceSDK mBTHSocket

List of usage examples for org.apache.cordova.plugin HXiMateDeviceSDK mBTHSocket

Introduction

In this page you can find the example usage for org.apache.cordova.plugin HXiMateDeviceSDK mBTHSocket.

Prototype

BluetoothSocket mBTHSocket

To view the source code for org.apache.cordova.plugin HXiMateDeviceSDK mBTHSocket.

Click Source Link

Usage

From source file:com.mega.credit.Credit.java

License:Apache License

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    super.init();
    super.setIntegerProperty("splashscreen", R.drawable.splash);
    View view = LayoutInflater.from(this).inflate(R.layout.urltext, null);
    final EditText eturl = (EditText) view.findViewById(R.id.et_url);
    eturl.setText(MyConstants.spf.getString("url", ""));
    RadioGroup rg01 = (RadioGroup) view.findViewById(R.id.rg01);
    rg01.setVisibility(View.INVISIBLE);
    final RadioButton rb_yd = (RadioButton) view.findViewById(R.id.rb_yd);
    final RadioButton rb_zd = (RadioButton) view.findViewById(R.id.rb_zd);
    final RadioButton rb_bj = (RadioButton) view.findViewById(R.id.rb_bj);
    rb_bj.setButtonDrawable(R.drawable.checkbox_checked_style);
    rb_zd.setButtonDrawable(R.drawable.checkbox_checked_style);
    rb_yd.setButtonDrawable(R.drawable.checkbox_checked_style);
    MyConstants.setPowerOnSFZ();//from w w w.ja  v  a 2s. co  m
    if (MyConstants.spf.getInt("cardreader_type", 0) == 1) {
        rb_zd.setChecked(true);
    } else if (MyConstants.spf.getInt("cardreader_type", 0) == 2) {
        rb_bj.setChecked(true);
    } else if (MyConstants.spf.getInt("cardreader_type", 0) == 3) {
        rb_yd.setChecked(true);
    }
    new AlertDialog.Builder(this).setTitle("").setView(view).setCancelable(false)
            .setPositiveButton("", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    Intent exit = new Intent(Intent.ACTION_MAIN);
                    exit.addCategory(Intent.CATEGORY_HOME);
                    exit.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    startActivity(exit);
                    try {
                        if (HXiMateDeviceSDK.mBTHSocket != null) {
                            HXiMateDeviceSDK.mBTHSocket.close();
                        }
                        if (HXiMateDeviceSDK.mmInStream != null) {
                            HXiMateDeviceSDK.mmInStream.close();
                        }
                        if (HXiMateDeviceSDK.mmOutStream != null) {
                            HXiMateDeviceSDK.mmOutStream.close();
                        }
                    } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                    System.exit(0);
                }
            }).setNegativeButton("", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    String url = eturl.getText().toString();
                    Field field;
                    try {
                        field = dialog.getClass().getSuperclass().getDeclaredField("mShowing");
                        field.setAccessible(true);
                        if (rb_zd.isChecked() == true) {
                            MyConstants.editor.putInt("cardreader_type", 1);
                        } else if (rb_bj.isChecked() == true) {
                            MyConstants.editor.putInt("cardreader_type", 2);
                        } else if (rb_yd.isChecked() == true) {
                            MyConstants.editor.putInt("cardreader_type", 3);
                        }
                        //               MyConstants.editor.putInt("cardreader_type", 100);//
                        MyConstants.editor.putInt("cardreader_type", 1);//
                        //               MyConstants.editor.putInt("cardreader_type", 2);//
                        //               MyConstants.editor.putInt("cardreader_type", 3);//
                        MyConstants.editor.commit();
                        if (url.trim().equals("")) {
                            Toast.makeText(Credit.this, "URL", Toast.LENGTH_SHORT).show();
                            field.set(dialog, false);// dialog
                        } else {
                            field.set(dialog, true);// dialog
                            loadUrl(url, 3000);
                        }
                        MyConstants.editor.putString("url", url);
                        MyConstants.editor.commit();

                    } catch (NoSuchFieldException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    } catch (IllegalAccessException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    } catch (IllegalArgumentException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                }
            }).setMessage("URL").show();
}

From source file:com.mega.credit.Credit.java

License:Apache License

/**
 * /*from   ww  w.j  a va2 s.c  o m*/
 *   : quit
 *   :  
 *  
 *
 *  
 *     2014-4-28 11:46:33   kcx
 *        
 *
 */
private void quit() {
    new AlertDialog.Builder(this).setTitle("")
            .setPositiveButton("", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    count = 0;
                    Intent exit = new Intent(Intent.ACTION_MAIN);
                    exit.addCategory(Intent.CATEGORY_HOME);
                    exit.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    startActivity(exit);
                    try {
                        if (HXiMateDeviceSDK.mBTHSocket != null) {
                            HXiMateDeviceSDK.mBTHSocket.close();
                        }
                        if (HXiMateDeviceSDK.mmInStream != null) {
                            HXiMateDeviceSDK.mmInStream.close();
                        }
                        if (HXiMateDeviceSDK.mmOutStream != null) {
                            HXiMateDeviceSDK.mmOutStream.close();
                        }
                    } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                    System.exit(0);
                }
            }).setNegativeButton("", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    count = 0;
                    dialog.cancel();
                }
            }).setMessage("?").show();
}