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