After the scan to automatically open Activity?

Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
In my app there is a scanner "zxing". I need to after the scan is opened "activity_scanner".

Code scanner:
public class ScannerActivity extends AppCompatActivity { static final String ACTION_SCAN = ""; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R. layout.activity_scanner); } /*Start the qr code scanner:*/ public void scanQR(View v) { try { /*Start the transition to through intent:*/ Intent intent = new Intent(ACTION_SCAN); intent.putExtra("SCAN_MODE", "QR_CODE_MODE"); startActivityForResult(intent, 0); } catch (ActivityNotFoundException anfe) { /*It is possible to download from Play Market:*/ showDialog(ScannerActivity.this "Scanner not found", "to Install the scanner from Play Market?", "Yes", "No").show(); } } /*alert dialog to access the app download of scanner:*/ private static AlertDialog showDialog(final Activity act, CharSequence title, CharSequence message,CharSequence buttonYes, CharSequence buttonNo) { AlertDialog.Builder downloadDialog = new AlertDialog.Builder(act); downloadDialog.setTitle(title); downloadDialog.setMessage(message); downloadDialog.setPositiveButton(buttonYes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialogInterface, int i) { /*Link the search request to download the app:*/ Uri uri = Uri.parse("market://search?q=pname:" + ""); Intent intent = new Intent(Intent.ACTION_VIEW, uri); try { act.startActivity(intent); } catch (ActivityNotFoundException anfe) { } } }); downloadDialog.setNegativeButton(buttonNo, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialogInterface, int i) { } }); return; } /*Process the result obtained from the application of the scanner:*/ public void onActivityResult(int requestCode, int resultCode, Intent intent) { if (requestCode == 0) { if (resultCode == RESULT_OK) { /*Get the data after operation of the scanner and display them in Toast the message:*/ String contents = intent.getStringExtra("SCAN_RESULT"); String format = intent.getStringExtra("SCAN_RESULT_FORMAT"); Toast toast = Toast.makeText(this, "Content:" + contents + "Format:" + format, Toast.LENGTH_LONG);; startActivity(intent); } } } }

by | 11 views

1 Answer

0 like 0 dislike
In the method "onActivityResult()" argument "intent" is only to return the scanned barcode.

No "startActivity(intent)" with him to perform.

If you want to leave on the screen the activity, which was to run scanner, it will happen automatically.

But if you want to run another activity - make a new intent:

Intent next = new Intent(this, NextActivity.class);
110,608 questions
257,186 answers
35,574 users