This commit is contained in:
ろむねこ 2024-01-17 16:55:05 +09:00
parent 8bd8900286
commit c09ba30fa1
No known key found for this signature in database
GPG Key ID: FA1F39A1BA37D168

View File

@ -80,17 +80,18 @@ public class MainActivity extends AppCompatActivity {
private final ActivityResultLauncher<ScanOptions> QrLauncher = registerForActivityResult( private final ActivityResultLauncher<ScanOptions> QrLauncher = registerForActivityResult(
new ScanContract(), new ScanContract(),
result -> { result -> {
if (result != null) { String contents = result.getContents();
String url = result.getContents(); if (contents == null) {
Log.d("QRFragment", "onActivityResult: " + url); Toast.makeText(this, "QRコードが読み取れませんでした", Toast.LENGTH_LONG).show();
if (url != null) { } else if (!contents.contains("https://practicefirestore1-8808c.web.app/")) {
Uri uri = Uri.parse(url); Toast.makeText(this, "Chiled Guardに対応するQRコードではありません", Toast.LENGTH_LONG).show();
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
CustomTabsIntent customTabsIntent = builder.build();
customTabsIntent.launchUrl(this, uri);
}
} else { } else {
Log.d("QRFragment", "onActivityResult: null"); //URLの表示
Toast.makeText(this, contents, Toast.LENGTH_SHORT).show();
//ブラウザを起動しURL先のサイトを開く
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
CustomTabsIntent customTabsIntent = builder.build();
customTabsIntent.launchUrl(this, Uri.parse(contents));
} }
} }
); );