Answer the question
In order to leave comments, you need to log in
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
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.
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>
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();
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question