Merge pull request #8 from child-guardian/rca/add_chrome_custom_tabs

Rca/add chrome custom tabs
This commit is contained in:
ろむねこ 2024-01-11 16:57:58 +09:00 committed by GitHub
commit 18636c661c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 2 deletions

View File

@ -64,4 +64,6 @@ dependencies {
androidTestImplementation 'androidx.test.ext:junit:1.1.5' androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
implementation 'com.journeyapps:zxing-android-embedded:4.3.0'//QR用zxingライブラリ implementation 'com.journeyapps:zxing-android-embedded:4.3.0'//QR用zxingライブラリ
implementation 'androidx.browser:browser:1.5.0'
} }

View File

@ -2,10 +2,12 @@ package com.example.childguard;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import androidx.activity.result.ActivityResultLauncher; import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContracts; import androidx.activity.result.contract.ActivityResultContracts;
import androidx.browser.customtabs.CustomTabsIntent;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import android.util.Log; import android.util.Log;
@ -20,6 +22,8 @@ import com.google.zxing.integration.android.IntentResult;
import com.journeyapps.barcodescanner.ScanContract; import com.journeyapps.barcodescanner.ScanContract;
import com.journeyapps.barcodescanner.ScanOptions; import com.journeyapps.barcodescanner.ScanOptions;
import java.util.Objects;
/** /**
* A simple {@link Fragment} subclass. * A simple {@link Fragment} subclass.
* Use the {@link QRFragment#newInstance} factory method to * Use the {@link QRFragment#newInstance} factory method to
@ -83,8 +87,12 @@ public class QRFragment extends Fragment {
// dataPass.onDataPass(result.getContents()); // dataPass.onDataPass(result.getContents());
//画面遷移 //画面遷移
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); // Intent intent=new Intent(getActivity(),UrlPageActivity.class);
startActivity(intent); // startActivity(intent);
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
CustomTabsIntent customTabsIntent = builder.build();
customTabsIntent.launchUrl(requireContext(), Uri.parse(result.getContents()));
} }
}); });