Skip to content Skip to sidebar Skip to footer

Android - How To Pass Another Activity Application Context From Java Class Extends Fragments To Asynctask?

Hi I am trying to make application that has view pager and tablayout. So when I choose 'friends' tab layout it will call java class named FragFriends.java, In this class I want to

Solution 1:

Change this:

PHPUserListphpUserList=newPHPUserList(dview.getContext()); 
phpUserList.execute();

to :

new PHPUserList(getActivity()).execute();

Solution 2:

In your fragment class just put getActivity(), where Context is needed it will do the job!

Solution 3:

just use getContext();

This does the work. In case you need to use the Activity Context then Have static context of ClassName.this

Post a Comment for "Android - How To Pass Another Activity Application Context From Java Class Extends Fragments To Asynctask?"