Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
- return inflater.inflate(R.layout.fragment_home, container, false)
- }
- override fun onActivityCreated(savedInstanceState: Bundle?) {
- super.onActivityCreated(savedInstanceState)
- val mScanner = IntentIntegrator(activity)
- mScanner.setDesiredBarcodeFormats(IntentIntegrator.QR_CODE)
- mScanner.setBeepEnabled(true)
- mScanner.initiateScan()
- }
- override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
- val result = IntentIntegrator.parseActivityResult(requestCode, resultCode, data)
- if (result != null) {
- if (result.contents == null) {
- Toast.makeText(activity, "Cancelled", Toast.LENGTH_LONG).show()
- } else {
- Toast.makeText(activity, "Scanned: " + result.contents, Toast.LENGTH_LONG).show()
- }
- } else {
- super.onActivityResult(requestCode, resultCode, data)
- }
- }
- }
- I want to get response in a toast but when I tried to use debugger I am unable to go to onActivityResult() and the camera closes quickly.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement