Skip to content

Instantly share code, notes, and snippets.

@amitshekhariitbhu
Last active January 26, 2017 09:45
Show Gist options
  • Save amitshekhariitbhu/32bb86ec40a9032f29e962eaf995cd86 to your computer and use it in GitHub Desktop.
Save amitshekhariitbhu/32bb86ec40a9032f29e962eaf995cd86 to your computer and use it in GitHub Desktop.
public class SubscriptionActivity extends Activity {
Subscription subscription;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
subscription = getObservable()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(getDummyObserver());
}
@Override
protected void onDestroy() {
super.onDestroy();
// unsubscribe it when activity onDestroy is called
subscription.unsubscribe();
}
public Observable<String> getObservable() {
return RxAndroidNetworking.download(URL, dirPath, fileName)
.build()
.getDownloadObservable();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment