开发者

Android hidden activity async calls

开发者 https://www.devze.com 2023-04-01 01:32 出处:网络
I am new to android and I am building an Android library where I have a weird use case like the following:

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消