Start an app from a fragment


I have an app that launches a notification and another app that collects it. The problem is that the activity that collects the intent I want not to be initialized in a activity as always but I want to do it in a fragment . Do they know in any way? Thanks

asked by Donis 30.11.2016 в 14:59

1 answer


You have to start an Activity ( FragmentActivity ) since this is what the Fragment can contain, a Fragment can not be isolated from an Activity.

Simply perform the Fragment transaction that you want when you start the onCreate() method of the FragmentActivity.

              // Carga nuevo fragmento deseado mediante una transacción.
              Fragment nuevoFragmento = new myFragment();
              FragmentTransaction transaction = getFragmentManager().beginTransaction();
              transaction.replace(, nuevoFragmento);
              // Commit a la transacción
answered by 30.11.2016 в 16:00