Merge remote-tracking branch 'origin/main'

This commit is contained in:
磯野 2024-01-11 16:52:16 +09:00
commit 4beef55f9e
2 changed files with 7 additions and 5 deletions

View File

@ -34,6 +34,7 @@
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity> </activity>
<activity android:name=".UrlPageActivity" />
</application> </application>
</manifest> </manifest>

View File

@ -27,7 +27,7 @@ import com.journeyapps.barcodescanner.ScanOptions;
*/ */
public class QRFragment extends Fragment { public class QRFragment extends Fragment {
//QRコードから受け取ったURLの受け渡しの宣言 //QRコードから受け取ったURLの受け渡しの宣言
OnDataPass dataPass; // OnDataPass dataPass;
// TODO: Rename parameter arguments, choose names that match // TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private static final String ARG_PARAM1 = "param1"; private static final String ARG_PARAM1 = "param1";
@ -71,17 +71,18 @@ public class QRFragment extends Fragment {
} }
//FragmentからActivityへデータの受け渡しをするためのInterface //FragmentからActivityへデータの受け渡しをするためのInterface
public interface OnDataPass{ // public interface OnDataPass{
void onDataPass(String urlPass); // void onDataPass(String urlPass);
} // }
private final ActivityResultLauncher<ScanOptions> fragmentLauncher = registerForActivityResult(new ScanContract(), private final ActivityResultLauncher<ScanOptions> fragmentLauncher = registerForActivityResult(new ScanContract(),
result -> { result -> {
//QRコードからデータを読み取れたかの確認 //QRコードからデータを読み取れたかの確認
if(result.getContents() == null) { if(result.getContents() == null) {
Toast.makeText(getContext(), "Cancelled from fragment", Toast.LENGTH_LONG).show(); Toast.makeText(getContext(), "Cancelled from fragment", Toast.LENGTH_LONG).show();
} else { } else {
dataPass.onDataPass(result.getContents()); // dataPass.onDataPass(result.getContents());
//画面遷移 //画面遷移
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);
} }