예제 #1
0
    @Override
    public void onClick(View v) {
      String label = ((Button) v).getText().toString();
      String positive = activity.getString(R.string.alert_pos);
      if (label.equals(positive)) {
        String recipient = activity.getString(R.string.email);
        String subject = activity.getString(R.string.subject);
        String type = activity.getString(R.string.type);

        // get stacktrace as string
        StringWriter sw = new StringWriter();
        e.printStackTrace(new PrintWriter(sw));
        String body = sw.toString();

        Intent i = new Intent(Intent.ACTION_SEND);
        i.setType(type);
        i.putExtra(Intent.EXTRA_EMAIL, new String[] {recipient});
        i.putExtra(Intent.EXTRA_SUBJECT, subject);
        i.putExtra(Intent.EXTRA_TEXT, body);

        try {
          activity.startActivity(Intent.createChooser(i, "Send email"));
        } catch (android.content.ActivityNotFoundException ex) {
        }
      }

      dialog.dismiss();
    }
예제 #2
0
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.activity_message);
   mQRCodeImage = (ImageView) findViewById(R.id.qrcode_image);
   final WindowManager manager = (WindowManager) getSystemService(WINDOW_SERVICE);
   final Display display = manager.getDefaultDisplay();
   Point displaySize = new Point();
   display.getSize(displaySize);
   final int width = displaySize.x;
   final int height = displaySize.y;
   final int dimension = width < height ? width : height;
   mEncoder =
       new QRCodeEncode.Builder()
           .setBackgroundColor(0xFFFFFF)
           .setCodeColor(0XFF3F51B5)
           .setOutputBitmapPadding(2)
           .setOutputBitmapWidth(dimension)
           .setOutputBitmapHeight(dimension)
           .build();
   mDecodeTask = new DecodeTask();
   if (SpUtils.contains(this, "name")) {
     sendMessage();
   } else {
     Toast.makeText(this, "未输入名字", Toast.LENGTH_SHORT).show();
     View view = View.inflate(this, R.layout.input_time, null);
     EditText editText = (EditText) view.findViewById(R.id.input_name);
     materialDialog =
         new MaterialDialog(this)
             .setTitle("设定名字")
             .setContentView(view)
             .setPositiveButton(
                 "确定",
                 v -> {
                   if (!editText.getText().toString().equals("")) {
                     SpUtils.put(this, "name", editText.getText().toString());
                     Toast.makeText(
                             this, "设定名字为" + editText.getText().toString(), Toast.LENGTH_SHORT)
                         .show();
                   }
                   materialDialog.dismiss();
                 });
     materialDialog.show();
   }
   findViewById(R.id.button_start).setOnClickListener(this);
   findViewById(R.id.button_share).setOnClickListener(this);
 }
 public void dismiss() {
   mDialog.dismiss();
 }