Qr #9
|
@ -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()));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user