dimanche 19 novembre 2023

Get activity Name from a superstructure

Here is my problem.

I successfully used a navigation drawer which overlays with no problems with EVERY activity in my App, modifying a template. There is a float button which I want to use like a pc F1 key, that sholud trigger a "help hint" or a "help screen" for the current activity.

To do that I obviously need the current activity. thing is if I use the classic reflection solution, all that i get back is class linked to the navigation menu overlay.

using debbuging i was searching for some... "property" like "child" or "active activity" or something like this, but i found none. The navigation overlays with no interference but has no information of what it is overlaying. Is there an hidden property?

Should i have to set a global variabile that i can retrieve where the float button is declared? i don't want to set helps buttons, everywhere T_T

protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        binding = ActivityDrawerProvaBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());

        //Comando che lega invoca il Navigation Drawer
        setSupportActionBar(binding.appBarDrawerProva.toolbar);
        binding.appBarDrawerProva.F1Touch.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                String mess = getApplicationContext().toString();
                Snackbar.make(view,mess, Snackbar.LENGTH_LONG)
                        .setAction("Action", null).show();
            }
        });
        DrawerLayout drawer = binding.drawerLayout;
        NavigationView navigationView = binding.navView;
        // Passing each menu ID as a set of Ids because each
        // menu should be considered as top level destinations.

        //Qui dovrebbero aggiungersi i collegamenti alle finestre per ogni voce di menu???
        mAppBarConfiguration = new AppBarConfiguration.Builder(
                R.id.nav_home, R.id.reverse_Matrix, R.id.forma_standard)
                .setOpenableLayout(drawer)
                .build();
        NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment_content_drawer_prova);
        NavigationUI.setupActionBarWithNavController(this, navController, mAppBarConfiguration);
        NavigationUI.setupWithNavController(navigationView, navController);
    }

here is the code in which the action of the button should be triggered (his name is F1touch)

I know, as it this it can only get the context of which the button is declared, but i want the overlayed activity.

that's what i get in every activity

"easy" suggestion? --'





Aucun commentaire:

Enregistrer un commentaire