Last active
December 29, 2015 10:19
-
-
Save n0ne/7656407 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
onResponse: | |
mBroadcastIntent = new Intent(); | |
mBroadcastIntent.setAction(myReciever.PROCESS_RESPONSE); | |
mBroadcastIntent.putExtra("value", result); | |
getActivity().sendBroadcast(mBroadcastIntent); | |
In Activity/Fragment create class: | |
public class myReciever extends BroadcastReceiver { | |
public static final String PROCESS_RESPONSE = "<your name uri>.network.intent.action.PROCESS_RESPONSE"; | |
int value; | |
@Override | |
public void onReceive(Context context, Intent intent) { | |
Bundle extras = intent.getExtras(); | |
if (extras != null) { | |
value = extras.getInt("value", 0); | |
} | |
} | |
} | |
Add in onCreate/onResume: | |
IntentFilter filter = new IntentFilter(myReciever.PROCESS_RESPONSE); | |
mReciever = new myReciever(); | |
getActivity().registerReceiver(mReciever, filter); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment