Skip to content

Instantly share code, notes, and snippets.

@n0ne
Last active December 29, 2015 10:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save n0ne/7656407 to your computer and use it in GitHub Desktop.
Save n0ne/7656407 to your computer and use it in GitHub Desktop.
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