• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Unable to implement implicit intent (Kotlin)

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm currently working on an Android application that focuses on scanning QR codes in which I'm using this library. Upon launch, the application returns the URL of the scanned QR code like so. However, my question revolves around how I can take this returned result and then launch it into a web browser on the device. I'm merely confused as to why the implementation shown near the bottom in the following code doesn't appear to launch the returned result from the QR code right into the web browser.

According to this documentation, I should be implementing the searchWeb() function in order to fire off the intent, and as you can see below, I did. I also called searchWeb() within the onCreate method (which is where I'm supposed to call it from, right?). However, the application is still not firing off the implicit intent upon scanning. Can anybody tell me why?

 
Bartender
Posts: 217
7
Android Python Oracle Postgres Database Java Linux
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Shouldn't the searchWeb(query) be called only when something has been scanned in. In your code the call is done even before the CodeScanner is started?

I assume that the search string is known only inside  codeScanner.decodeCallback. Subsequently, searchWeb( ... ) call should be probably put into this callback:

 
Mason Buchanan
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@RolandMueller You're absolutely right. That's precisely where I should be calling the searchWeb() function from. However, while the web browser does what it's intended to do, it still doesn't take the string and launch that into the web browser.

To answer your question, yes, the search string is only known inside codeScanner.decodeCallback. Would I have to change or move the string in order to have the result passed on into a web browser?
 
Mason Buchanan
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moreso, wherein exactly would this issue lie?

Within the codeScanner.decodeCallback or within the searchWeb function? Knowing this would be a huge indicator on the steps I'd need to take.
 
Roland Mueller
Bartender
Posts: 217
7
Android Python Oracle Postgres Database Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I had no time to try this by myself, but I think the codeScanner.decodeCallback should be OK when the call to the search function is placed here.

Inside the search function you may try to omit the call to intent.resolveActivity() (lines 42 - 44 in your code). Instead please try to call startActivity( intent ) from line 43.



Here is some discussion about the topic from Stackoverflow. As said I haven't (yet) tried out any code myself, but after reading this I am quite confident that this should be the solution.

Stackoverflow:  intent.resolveActivity returns null in API 30


 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic