Skip to content

Instantly share code, notes, and snippets.

@nalitzis
Last active December 12, 2015 08:09
Show Gist options
  • Save nalitzis/4742111 to your computer and use it in GitHub Desktop.
Save nalitzis/4742111 to your computer and use it in GitHub Desktop.
private class IncomingHandler extends Handler{
public void handleMessage(Message msg){
Bundle data = msg.getData();
String title = data.getString("TITLE");
int pid = Process.myPid();
Toast.makeText(getApplicationContext(), title + "\nservice pid: "+pid, Toast.LENGTH_SHORT).show();
}
}
private final Messenger messenger = new Messenger(new IncomingHandler());
//the IBinder returned here is used by the messenger to communicate with the associated handler
@Override
public IBinder onBind(Intent arg0) {
return messenger.getBinder();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment