From eb4e3b4a38acedc62cb883843a3a654fb28b5889 Mon Sep 17 00:00:00 2001 From: it232115 Date: Fri, 12 Jan 2024 11:34:16 +0900 Subject: [PATCH] =?UTF-8?q?=E8=AA=AD=E3=81=BF=E5=8F=96=E3=81=A3=E3=81=9FQR?= =?UTF-8?q?=E3=82=B3=E3=83=BC=E3=83=89=E3=81=8CChiled=20Guard=E7=94=A8?= =?UTF-8?q?=E3=82=B5=E3=82=A4=E3=83=88=E3=81=AE=E3=83=89=E3=83=A1=E3=82=A4?= =?UTF-8?q?=E3=83=B3=E3=82=92=E5=90=AB=E3=82=80=E3=81=8B=E3=81=AE=E5=88=A4?= =?UTF-8?q?=E5=AE=9A=E3=82=92=E8=A1=8C=E3=81=86=E5=87=A6=E7=90=86=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0=E3=81=97=E3=81=BE=E3=81=97=E3=81=9F=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/example/childguard/QRFragment.java | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/com/example/childguard/QRFragment.java b/app/src/main/java/com/example/childguard/QRFragment.java index ed63a6a..fc0e0a8 100644 --- a/app/src/main/java/com/example/childguard/QRFragment.java +++ b/app/src/main/java/com/example/childguard/QRFragment.java @@ -74,22 +74,16 @@ public class QRFragment extends Fragment { } - //FragmentからActivityへデータの受け渡しをするためのInterface -// public interface OnDataPass{ -// void onDataPass(String urlPass); -// } private final ActivityResultLauncher fragmentLauncher = registerForActivityResult(new ScanContract(), result -> { - //QRコードからデータを読み取れたかの確認 - if(result.getContents() == null) { - Toast.makeText(getContext(), "Cancelled from fragment", Toast.LENGTH_LONG).show(); + //result.getContents()でURLを入手 + //読み取ったQRコードがChiled Guard用サイトのドメインを含むかの判定 + if(!((result.getContents()).contains("https://practicefirestore1-8808c.web.app/"))) { + Toast.makeText(getContext(), "Chiled Guardに対応するQRコードではありません", Toast.LENGTH_LONG).show(); } else { -// dataPass.onDataPass(result.getContents()); - //画面遷移 + //URLの表示 Toast.makeText(getContext(), result.getContents(), Toast.LENGTH_SHORT).show(); -// Intent intent=new Intent(getActivity(),UrlPageActivity.class); -// startActivity(intent); - + //ブラウザを起動し、URL先のサイトを開く CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder(); CustomTabsIntent customTabsIntent = builder.build(); customTabsIntent.launchUrl(requireContext(), Uri.parse(result.getContents()));