1

I am creating an android app that have some page with information read from the sqlite database and a qr code reader built in the app, but i have question to ask

This is my question :

when i read the qr code which contain some IDs, is it possible to link/bring to a particular page that have that IDs ?

I try to google for information about this, but i did not find any sample code or tutorial that teach how to link from qr code to particular part in the android app. From all the google information i found, i only know that i need a url, then how can i generate a url to link to the android app? does it mean that i have to create a website?

MY MAIN IDEA:

in my android app have information:

Page 1:
Apple 
cost 1 dollar

Page 2: 
Pear 
cost 1.50 dollar

What i want to do: Scan qr code from my android, reader retrieve Page 1 as ID, then link/go to Page 1 in the android app

I just want go to or link to that particular activity1(page1) after scan the qr code that contain 1 within that same app

Harshad Pansuriya
  • 20,189
  • 8
  • 67
  • 95
cutexxbaby
  • 23
  • 1
  • 8

2 Answers2

0

To open url from android app use this:

String url = "http://www.example.com/YOUR-ID-GENERATED_PAGE";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);

source page here on StackOverflow

Community
  • 1
  • 1
berc
  • 16
  • hi @berc, just a question , my reader is inbuilt and pages of information are all in the same android app, when i scan the qr code from the inbuilt reader i want to directly go to the particular page within the same android app, does it still need url to navigate?if yes,how can i create that url ? – cutexxbaby Dec 15 '14 at 15:37
  • you can use WebView. A View that displays web pages. This class is the basis upon which you can roll your own web browser or simply display some online content within your Activity. More info about [WebView in Android Javadocs](http://developer.android.com/reference/android/webkit/WebView.html). – berc Dec 15 '14 at 15:47
  • i am a bit confuse, i dont want to show those content on the web browser, i just want it on the android app and all the content are retrieve from the sqlite database sothere no online content. I just want go to or link to that particular activity1 after scan the qr code contain 1 in that same app. Why does it need webview since i no need roll my own web browser or display online content within my activity? – cutexxbaby Dec 15 '14 at 16:01
  • okej, in that case you can use simple call startActivity or startActivityForResult and set extra Bundle with ID. In started activity (onCreate function or Fragment onCreateView) implement switch witch show informations based on received ID. – berc Dec 15 '14 at 16:38
  • do you have a tutorial or sample code or reference that i can see to try out what you have mention in the above comment, thanks a lot – cutexxbaby Dec 16 '14 at 04:22
0

You can use TEXT format of QR code to return a text rather than a URL. In your case, the returned text could be an ID. Map your IDs with the Activities you are intended to awake after scanning.Then check the ID and start your mapped Activity manually in your application.

Parinda Rajapaksha
  • 2,963
  • 1
  • 36
  • 40