Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
  2. return inflater.inflate(R.layout.fragment_home, container, false)
  3. }
  4. override fun onActivityCreated(savedInstanceState: Bundle?) {
  5. super.onActivityCreated(savedInstanceState)
  6. val mScanner = IntentIntegrator(activity)
  7. mScanner.setDesiredBarcodeFormats(IntentIntegrator.QR_CODE)
  8. mScanner.setBeepEnabled(true)
  9. mScanner.initiateScan()
  10.  
  11. }
  12. override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
  13. val result = IntentIntegrator.parseActivityResult(requestCode, resultCode, data)
  14. if (result != null) {
  15. if (result.contents == null) {
  16. Toast.makeText(activity, "Cancelled", Toast.LENGTH_LONG).show()
  17. } else {
  18. Toast.makeText(activity, "Scanned: " + result.contents, Toast.LENGTH_LONG).show()
  19. }
  20. } else {
  21. super.onActivityResult(requestCode, resultCode, data)
  22. }
  23. }
  24. }
  25.  
  26. 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