Beginning of action from a fragment of dialogue

I have a fragment of a dialog attached to the main operation, and is there a way by which I can launch another action from the dialog using the Click button.

My call with DialogFragment call:

Intent i= new Intent(getActivity(),SecondActivity.class);

startActivity(i);

Registered a second activity in

Manifest.xml

as below

<activity android:name=".SecondActivity" 

          android:label="@string/app_name"  

          android:theme="@android:style/Theme.Dialog">

  <intent-filter>

        <action android:name="com.example.testjsoncall.SecondActivity" />
        <category android:name="android.intent.category.DEFAULT" />

  </intent-filter>

</activity>
+3
source share
2 answers

Hope this helps you :)

Intent i= new Intent(context,SecondActivity.class);

context.startActivity(i);
+6
source

getActivity()returns the context of the current activity. You need the context of the dialog fragment to get the context there.

So in your DialogFragment use MyActivity.this as your context

Hope this works

+3
source

All Articles