Qr #9

Merged
r-ca merged 4 commits from QR into main 2024-01-12 02:36:57 +00:00
Showing only changes of commit eb4e3b4a38 - Show all commits

View File

@ -74,22 +74,16 @@ public class QRFragment extends Fragment {
} }
//FragmentからActivityへデータの受け渡しをするためのInterface
// public interface OnDataPass{
// void onDataPass(String urlPass);
// }
private final ActivityResultLauncher<ScanOptions> fragmentLauncher = registerForActivityResult(new ScanContract(), private final ActivityResultLauncher<ScanOptions> fragmentLauncher = registerForActivityResult(new ScanContract(),
result -> { result -> {
//QRコードからデータを読み取れたかの確認 //result.getContents()でURLを入手
if(result.getContents() == null) { //読み取ったQRコードがChiled Guard用サイトのドメインを含むかの判定
Toast.makeText(getContext(), "Cancelled from fragment", Toast.LENGTH_LONG).show(); if(!((result.getContents()).contains("https://practicefirestore1-8808c.web.app/"))) {
Toast.makeText(getContext(), "Chiled Guardに対応するQRコードではありません", Toast.LENGTH_LONG).show();
} else { } else {
// dataPass.onDataPass(result.getContents()); //URLの表示
//画面遷移
Toast.makeText(getContext(), result.getContents(), Toast.LENGTH_SHORT).show(); Toast.makeText(getContext(), result.getContents(), Toast.LENGTH_SHORT).show();
// Intent intent=new Intent(getActivity(),UrlPageActivity.class); //ブラウザを起動しURL先のサイトを開く
// startActivity(intent);
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder(); CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
CustomTabsIntent customTabsIntent = builder.build(); CustomTabsIntent customTabsIntent = builder.build();
customTabsIntent.launchUrl(requireContext(), Uri.parse(result.getContents())); customTabsIntent.launchUrl(requireContext(), Uri.parse(result.getContents()));