Kobo App: Metadata_username value to send to MainMenuActivity.xml

43 views Asked by At

I just want to ask a question because I am customizing the Kobo app on my android device.

I just want to ask how I can get the metada_username value to be displayed in my MainMenuActivity.xml after I scan the QR code.

PS: the QR code is already customized and has a metada_username included. Also in my project settings, it is displaying the metadata_username from the QR in the Form Metadata.

Please somebody help me!! Thank you in advance!

1

There are 1 answers

1
Mori On

For example, if you want to get the metadata_username value from a QR code that contains a URL like this:

https://example.com/login?metadata_username=john&metadata_password=1234

You can use the ZXing library to scan the QR code and get the raw data as a string:

https://example.com/login?metadata_username=john&metadata_password=1234

Then you can use a URL parser library or method to parse the URL and get the query parameters as a map:

{metadata_username: john, metadata_password: 1234}

Finally, you can access the metadata_username value from the map by using its key:

String metadata_username = map.get ("metadata_username");

To display the metadata_username value in your MainMenuActivity.xml, you can use a TextView element and set its text attribute to the metadata_username value:

 <TextView android:id="@+id/metadata_username_text"
 android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:text="@{metadata_username}" />