Android Architecture Components - communication between Activity/Fragment and Service/IntentService
The answer to this question is providing me with a marvelous guide to how to use services in the Android Architecture Components/Jetpack environment.
It suggests that IntentServices should just plug into ViewModels via Repositories, as if they were any other data source, like a web service.
But neither that answer nor the Jetpack guide upon which it's based have much information about the so-called "Remote Data Source" object that would start and bind to the service, observe its LiveData and cascade it back up to the Repository.
What is it? An ordinary Java object that gets injected into the Repository? A singleton? Some special Lifecycle-aware subclass?
Where does it get the context it needs to start the service?
Is there example code you can point me to? If not, could you just sketch out the basics of what that would look like, including how its lifecycle would be linked to the lifecycle of the service itself, for newbies like me?
Thanks in advance!
android android-service-binding android-jetpack
add a comment |
The answer to this question is providing me with a marvelous guide to how to use services in the Android Architecture Components/Jetpack environment.
It suggests that IntentServices should just plug into ViewModels via Repositories, as if they were any other data source, like a web service.
But neither that answer nor the Jetpack guide upon which it's based have much information about the so-called "Remote Data Source" object that would start and bind to the service, observe its LiveData and cascade it back up to the Repository.
What is it? An ordinary Java object that gets injected into the Repository? A singleton? Some special Lifecycle-aware subclass?
Where does it get the context it needs to start the service?
Is there example code you can point me to? If not, could you just sketch out the basics of what that would look like, including how its lifecycle would be linked to the lifecycle of the service itself, for newbies like me?
Thanks in advance!
android android-service-binding android-jetpack
add a comment |
The answer to this question is providing me with a marvelous guide to how to use services in the Android Architecture Components/Jetpack environment.
It suggests that IntentServices should just plug into ViewModels via Repositories, as if they were any other data source, like a web service.
But neither that answer nor the Jetpack guide upon which it's based have much information about the so-called "Remote Data Source" object that would start and bind to the service, observe its LiveData and cascade it back up to the Repository.
What is it? An ordinary Java object that gets injected into the Repository? A singleton? Some special Lifecycle-aware subclass?
Where does it get the context it needs to start the service?
Is there example code you can point me to? If not, could you just sketch out the basics of what that would look like, including how its lifecycle would be linked to the lifecycle of the service itself, for newbies like me?
Thanks in advance!
android android-service-binding android-jetpack
The answer to this question is providing me with a marvelous guide to how to use services in the Android Architecture Components/Jetpack environment.
It suggests that IntentServices should just plug into ViewModels via Repositories, as if they were any other data source, like a web service.
But neither that answer nor the Jetpack guide upon which it's based have much information about the so-called "Remote Data Source" object that would start and bind to the service, observe its LiveData and cascade it back up to the Repository.
What is it? An ordinary Java object that gets injected into the Repository? A singleton? Some special Lifecycle-aware subclass?
Where does it get the context it needs to start the service?
Is there example code you can point me to? If not, could you just sketch out the basics of what that would look like, including how its lifecycle would be linked to the lifecycle of the service itself, for newbies like me?
Thanks in advance!
android android-service-binding android-jetpack
android android-service-binding android-jetpack
edited Nov 14 '18 at 3:53
John
asked Nov 14 '18 at 3:13
JohnJohn
1,02021026
1,02021026
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
Please follow this link. You will get your answer and also a basic implementation.
https://android.jlelse.eu/android-architecture-components-now-with-100-more-mvvm-11629a630125
Are you talking about the "RemoteRepository" that the blog refers to? I can't see an implementation of it, just references to it.
– John
Nov 14 '18 at 4:01
There is a reference to the full project. Here it is: github.com/JoaquimLey/transport-eta/tree/…
– Sultan Mahmud
Nov 14 '18 at 4:21
add a comment |
Why do you want to use the service? Remote Data Source typically means a layer that fetches data from your web back end API using a library such as Retrofit. You don't need a Service for that.
My service does audio recording. The answer I refer to above says that intent services can be treated as remote services for purposes of the JetPack architecture. But I'm open to other suggestions on where in the architecture I should start and bind to my services.
– John
Nov 14 '18 at 5:22
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53292669%2fandroid-architecture-components-communication-between-activity-fragment-and-se%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Please follow this link. You will get your answer and also a basic implementation.
https://android.jlelse.eu/android-architecture-components-now-with-100-more-mvvm-11629a630125
Are you talking about the "RemoteRepository" that the blog refers to? I can't see an implementation of it, just references to it.
– John
Nov 14 '18 at 4:01
There is a reference to the full project. Here it is: github.com/JoaquimLey/transport-eta/tree/…
– Sultan Mahmud
Nov 14 '18 at 4:21
add a comment |
Please follow this link. You will get your answer and also a basic implementation.
https://android.jlelse.eu/android-architecture-components-now-with-100-more-mvvm-11629a630125
Are you talking about the "RemoteRepository" that the blog refers to? I can't see an implementation of it, just references to it.
– John
Nov 14 '18 at 4:01
There is a reference to the full project. Here it is: github.com/JoaquimLey/transport-eta/tree/…
– Sultan Mahmud
Nov 14 '18 at 4:21
add a comment |
Please follow this link. You will get your answer and also a basic implementation.
https://android.jlelse.eu/android-architecture-components-now-with-100-more-mvvm-11629a630125
Please follow this link. You will get your answer and also a basic implementation.
https://android.jlelse.eu/android-architecture-components-now-with-100-more-mvvm-11629a630125
answered Nov 14 '18 at 3:31
Sultan MahmudSultan Mahmud
23017
23017
Are you talking about the "RemoteRepository" that the blog refers to? I can't see an implementation of it, just references to it.
– John
Nov 14 '18 at 4:01
There is a reference to the full project. Here it is: github.com/JoaquimLey/transport-eta/tree/…
– Sultan Mahmud
Nov 14 '18 at 4:21
add a comment |
Are you talking about the "RemoteRepository" that the blog refers to? I can't see an implementation of it, just references to it.
– John
Nov 14 '18 at 4:01
There is a reference to the full project. Here it is: github.com/JoaquimLey/transport-eta/tree/…
– Sultan Mahmud
Nov 14 '18 at 4:21
Are you talking about the "RemoteRepository" that the blog refers to? I can't see an implementation of it, just references to it.
– John
Nov 14 '18 at 4:01
Are you talking about the "RemoteRepository" that the blog refers to? I can't see an implementation of it, just references to it.
– John
Nov 14 '18 at 4:01
There is a reference to the full project. Here it is: github.com/JoaquimLey/transport-eta/tree/…
– Sultan Mahmud
Nov 14 '18 at 4:21
There is a reference to the full project. Here it is: github.com/JoaquimLey/transport-eta/tree/…
– Sultan Mahmud
Nov 14 '18 at 4:21
add a comment |
Why do you want to use the service? Remote Data Source typically means a layer that fetches data from your web back end API using a library such as Retrofit. You don't need a Service for that.
My service does audio recording. The answer I refer to above says that intent services can be treated as remote services for purposes of the JetPack architecture. But I'm open to other suggestions on where in the architecture I should start and bind to my services.
– John
Nov 14 '18 at 5:22
add a comment |
Why do you want to use the service? Remote Data Source typically means a layer that fetches data from your web back end API using a library such as Retrofit. You don't need a Service for that.
My service does audio recording. The answer I refer to above says that intent services can be treated as remote services for purposes of the JetPack architecture. But I'm open to other suggestions on where in the architecture I should start and bind to my services.
– John
Nov 14 '18 at 5:22
add a comment |
Why do you want to use the service? Remote Data Source typically means a layer that fetches data from your web back end API using a library such as Retrofit. You don't need a Service for that.
Why do you want to use the service? Remote Data Source typically means a layer that fetches data from your web back end API using a library such as Retrofit. You don't need a Service for that.
answered Nov 14 '18 at 4:59
Samuel RobertSamuel Robert
3,47552234
3,47552234
My service does audio recording. The answer I refer to above says that intent services can be treated as remote services for purposes of the JetPack architecture. But I'm open to other suggestions on where in the architecture I should start and bind to my services.
– John
Nov 14 '18 at 5:22
add a comment |
My service does audio recording. The answer I refer to above says that intent services can be treated as remote services for purposes of the JetPack architecture. But I'm open to other suggestions on where in the architecture I should start and bind to my services.
– John
Nov 14 '18 at 5:22
My service does audio recording. The answer I refer to above says that intent services can be treated as remote services for purposes of the JetPack architecture. But I'm open to other suggestions on where in the architecture I should start and bind to my services.
– John
Nov 14 '18 at 5:22
My service does audio recording. The answer I refer to above says that intent services can be treated as remote services for purposes of the JetPack architecture. But I'm open to other suggestions on where in the architecture I should start and bind to my services.
– John
Nov 14 '18 at 5:22
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53292669%2fandroid-architecture-components-communication-between-activity-fragment-and-se%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown