Untitled
unknown
plain_text
5 months ago
3.8 kB
3
Indexable
public class MainActivity extends AppCompatActivity { private SharedViewModel viewModel = null; private SavedBottomNavigationView mBottomNavigation = null; private FloatingActionButton fab_AR = null; private List<Integer> navGraphIds = null; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); initViewModel(); initNavigationView(); startNavigationService(); } @Override protected void onStart() { super.onStart(); } @Override protected void onDestroy() { super.onDestroy(); } @Override public void onBackPressed() { super.onBackPressed(); finishAffinity(); } private void initViewModel() { viewModel = new ViewModelProvider(this).get(SharedViewModel.class); } private void initNavigationView() { mBottomNavigation = findViewById(R.id.main__bottom_navigation); fab_AR = findViewById(R.id.fab_ar); navGraphIds = Arrays.asList( R.navigation.navigation_navigation, R.navigation.navigation_incidents, R.navigation.navigation_profile ); mBottomNavigation.setupWithNavController( navGraphIds, getSupportFragmentManager(), R.id.nav_host_fragment_activity_main, getIntent()); maybeEnableArButton(); fab_AR.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showARRoute(); } }); } void maybeEnableArButton() { } private void showARRoute(){ Intent intent = new Intent(this,ArCore.class); startActivity(intent); // Then, minimize the current activity into Picture-in-Picture mode // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { // Use PictureInPictureParams to set window attributes // PictureInPictureParams.Builder pipBuilder = new PictureInPictureParams.Builder(); // Rational aspectRatio = new Rational(16, 9); // Adjust aspect ratio if needed // pipBuilder.setAspectRatio(aspectRatio); // enterPictureInPictureMode(pipBuilder.build()); // } } // @Override // public void onUserLeaveHint() { // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { // // Handle if the user navigates away, enter PIP mode // PictureInPictureParams.Builder pipBuilder = new PictureInPictureParams.Builder(); // enterPictureInPictureMode(pipBuilder.build()); // } // super.onUserLeaveHint(); // } // @Override // public void onPictureInPictureModeChanged(boolean isInPictureInPictureMode, Configuration newConfig) { // super.onPictureInPictureModeChanged(isInPictureInPictureMode, newConfig); // if (isInPictureInPictureMode) { // // Update the UI for PIP mode if needed (e.g., hide some views) // } else { // // Restore the UI for full-screen mode if needed // } // } private void startNavigationService() { Constraints constraints = new Constraints.Builder().build(); OneTimeWorkRequest request = new OneTimeWorkRequest.Builder(NavigationWorker.class) .setExpedited(OutOfQuotaPolicy.RUN_AS_NON_EXPEDITED_WORK_REQUEST) .setConstraints(constraints) .build(); WorkManager.getInstance(getApplicationContext()).enqueue(request); } }
Editor is loading...
Leave a Comment