K
K
kovurado2021-12-11 10:13:03
Java
kovurado, 2021-12-11 10:13:03

How to make a site open with an offer to download the application when scanning a qr-code?

It is necessary to make it so that when scanning the quar code, my site opens, on which it will be written that people should download the application.
And if they scan the same cuar through my application, everything worked fine and opened.
How to do it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Roo, 2021-12-11
@xez

A QR code is just an encrypted string.
There is no magic there.
Based on this, your question is: “How to make such a line that a site opens with an offer to download the application?”
Answer: this line should contain a link to your site.

O
Oleg, 2021-12-11
@402d

The QR code contains just a link.
In the application manifest, write

<intent-filter>
                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.BROWSABLE" />
                <category android:name="android.intent.category.DEFAULT" />

                <data
                    android:host="lknpd.nalog.ru"
                    android:pathPrefix="/api/v1/receipt"
                    android:scheme="https" />
            </intent-filter>

Here you specify the host and start of the url. The code scanner application asks the operating system which programs can open this link. Yours will be added to the list of options.
void handleIntent(Intent intent){
        String action = intent.getAction();
        if (action == null) {
            showMessage("Ошибка вызова. Нет действия в намерении");
            return;
        }

        Uri uri = null;
        if (action.equals(Intent.ACTION_VIEW)) {
            uri = intent.getData();
        }else if (action.equals(Intent.ACTION_SEND) || action.equals(Intent.ACTION_SENDTO)) {
            String stringText = intent.getStringExtra(Intent.EXTRA_TEXT);
            if (stringText == null) {
                CharSequence textSequence = intent.getCharSequenceExtra(Intent.EXTRA_TEXT);
                if (textSequence != null) {
                    stringText = textSequence.toString();
                }
            }
            if (stringText != null) {
                if (stringText.startsWith("http://") || stringText.startsWith("https://")) {
                    uri = Uri.parse(stringText);
                }
            }
        }
        if(uri == null){
            showMessage("Ошибка вызова. Ссылка на чек не обнаружена");
            return;
        }
//теперь самостоятельно разбираете строку урла, чтобы вытащить нужные аргументы для конкретного действия в приложении
        receiptId = ReceiptId.fromURI(uri);
        if(receiptId == null){
            showMessage("Неправильная ссылка на чек");
            return;
        }

        importReceipt();
    }

On your website, URLs can be forwarded via htaccess to a stub with an offer to download the application or add a banner to a regular page with a suggestion to open it in the application.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question