I am studying on how to develop android sdk with gomobile, here is my use case:
The sdk will handle the file download and it will send its realtime received content to andoird, how could this be done?
I tried something like this, return a ReadCloser, then android will read from this stream :
func DownloadFile(url string) (io.ReadCloser, error) {
// download the file
resp, err := http.Get(url)
if err != nil {
return nil, err
}
if resp.StatusCode != http.StatusOK {
err = errors.New(fmt.Sprintf("requesrting url [%s] error [%s]!", url, resp.Status))
return nil, err
}
return resp.Body, nil
}
however from the compiled java class, there isn't even this method, why?
And I tried to return a channel, but it is the same result, not event compiled in target java class.
Is there any better way to do that? does gomobile supports callback (go sdk call this callback registered by android)? I can hardly find any documentation on that callback usage.