Auto send SMS to phone number after getting result from QR Code

  android, qr-code, sms

I’m new to Android/Java development. I’m trying to make an app in Android Studio that scans a QR Code and sends the scanned data automatically to a phone number. So far I have source code from a QR code Scanner I got from Github, runs well but it only scans and can’t get it to send the scanned data, what code do I need to add for that to happen. Thanks

Here is the Code

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    CodeScannerView scannerView = findViewById(R.id.scanner_view);
    mCodeScanner = new CodeScanner(this, scannerView);
    mCodeScanner.setDecodeCallback(new DecodeCallback() {
        @Override
        public void onDecoded(@NonNull final Result result) {
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    Toast.makeText(MainActivity.this, result.getText(), Toast.LENGTH_SHORT).show();
                    
                    
                }
            });
        }
    });
    scannerView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            mCodeScanner.startPreview();
        }
    });
}

@Override
protected void onResume() {
    super.onResume();
    mCodeScanner.startPreview();
}

@Override
protected void onPause() {
    mCodeScanner.releaseResources();
    super.onPause();
    
}

}

Source: Android Questions

LEAVE A COMMENT