Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "custom URI scheme sensor" for QR codes etc. #24

Open
aaaaalbert opened this issue Jun 12, 2015 · 3 comments
Open

Add "custom URI scheme sensor" for QR codes etc. #24

aaaaalbert opened this issue Jun 12, 2015 · 3 comments

Comments

@aaaaalbert
Copy link
Contributor

(Trying to summarize our latest discussion here --- feel free to add your thoughts!)

When you scan a QR code or tap a link in the browser, Android decides which app to supply the URI to depending on the scheme of the URI. For example, an https link will likely open in a new browser tab, market might open the Play store app, mailto the email client, etc.

We can define a custom URI scheme (see RFC3986 §3.1) for Sensibility Testbed, and then use this as a way to input data to running experiments. Then, a user of the app could scan a QR code conforming to our scheme, and the fact that this code has been scanned, together with the contents it encodes, are provided to a running experiment. (You can also add signatures etc. to the content so not everyone can spam your experiment).

The Android Part

You make the app aware of the custom scheme by adding an appropriate intent for the desired android:scheme to the app manifest, see the Android docs and a worked example (or so it seems). Note that this doesn't involve SL4A.

The Repy Part

On the Repy side of things, we need to figure out a couple of things.

Demultiplexing running experiments

We could ensure that only the correct experiment receives the data. On the other hand, maybe we just broadcast to all experiments that have the "scheme sensor" allowed by their IRB, and then they have to figure it out.

Notification method

How will an experiment learn that a custom scheme was sensed? This can go different ways, such as:

  • Look for a newly-created file containing the data
  • Listen on a server socket on localhost
  • Block on the sensor call
  • Poll using a specific scheme sensor call
  • Register a callback function that will be called with the data
  • Find data in a global variable
  • ....

What the blur?

Since it's a sensor (in our definition of the word), there could be blurring and readout/update frequency limits.

@yyzhuang
Copy link
Contributor

I read a bit about reading QR code. Most of the methods use a library called zxing, see this example. You can add two java classes into your project (first class, second class). I feel these two classes are just wrappers that you can use to fire an intent and get results. These two classes must use a barcode scanner app to do the actual scan. However, I also found a zxing class that uses camera to scan the QR code.

Hope this doesn't make things too complicated. The example code does show how to retrieve scanned result. So if our QR code can embed location coordinates at different places, these data can be returned to Android code. The rest is how to pass the data to repy code.

@aaaaalbert
Copy link
Contributor Author

zxing seems to access the camera etc. as well. Is this what we want? (I don't think so. I'd say we rely on the user to use the (stock) barcode reader installed on their device, and not bring ours that would need to be launched separately, i.e. from within our app).

@lukpueh
Copy link

lukpueh commented Mar 10, 2017

I started working on this today. But it still needs "some" fine tuning. I guess we'll have to wait until after the conference, to release this feature. For details see aaaaalbert@c256dfb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants