Skip to content

Instantly share code, notes, and snippets.

@nazmulidris
Created January 8, 2018 16:09
Show Gist options
  • Select an option

  • Save nazmulidris/23ff62a72315575f9d70c340dbc49a53 to your computer and use it in GitHub Desktop.

Select an option

Save nazmulidris/23ff62a72315575f9d70c340dbc49a53 to your computer and use it in GitHub Desktop.
public class MyIntentBuilder{
public static MyIntentBuilder getInstance(Context context) {
return new MyIntentBuilder(context);
}
public MyIntentBuilder(Context context) {
this.mContext = context;
}
public MyIntentBuilder setMessage(String message) {
this.mMessage = message;
return this;
}
public MyIntentBuilder setCommand(@Command int command) {
this.mCommandId = command;
return this;
}
public Intent build() {
Assert.assertNotNull("Context can not be null!", mContext);
Intent intent = new Intent(mContext, MyTileService.class);
if (mCommandId != Command.INVALID) {
intent.putExtra(KEY_COMMAND, mCommandId);
}
if (mMessage != null) {
intent.putExtra(KEY_MESSAGE, mMessage);
}
return intent;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment