修正
This commit is contained in:
parent
8bd8900286
commit
c09ba30fa1
|
@ -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();
|
||||||
|
} else {
|
||||||
|
//URLの表示
|
||||||
|
Toast.makeText(this, contents, Toast.LENGTH_SHORT).show();
|
||||||
|
//ブラウザを起動し、URL先のサイトを開く
|
||||||
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
|
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
|
||||||
CustomTabsIntent customTabsIntent = builder.build();
|
CustomTabsIntent customTabsIntent = builder.build();
|
||||||
customTabsIntent.launchUrl(this, uri);
|
customTabsIntent.launchUrl(this, Uri.parse(contents));
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Log.d("QRFragment", "onActivityResult: null");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user