Android hidden activity async calls
I am new to android and I am building an Android library where I have a weird use case like the following:
Method(parms...){
if(somedata exists in local filestore)
make webservice call and set result;
else
start activity with webview and get result from activity
}
}
If the first condition succeeds I would like it to make the webservice call asynchronously, while with the second, an activity is invoked which I think needs to be on the same thread to allow the caller to get the activity result.
I was thinking to use a hidden activity like the one found here. But i开发者_StackOverflow中文版t seems very hacky to me. Any other suggestions? I am thinking it might just be cleaner to have two separate methods in the library but I would like to keep them together if possible.
An Activity without UI, do you mean a Service? Please read this document. It describes how to do synchronous and async calls to this service.
精彩评论