简体   繁体   中英

Android: how to add app to “Share via” list for camera picture when there's no internet connection

I use this technique: http://webcache.googleusercontent.com/search?q=cache:gaSIT9QWcNcJ:eggie5.com/8-hook-share-picture-via-menu-android+&cd=1&hl=en&ct=clnk&gl=uk and it works amazingly. However, it works only when there's an internet connection. How can I make it work so when user doesn't have an internet connection, he shares the image to my app, and my app waits for internet to be available, and only then make a POST request? Current code doesn't make it work.

Or the only way to do it, is just save it to the external storage, and when user opens my application, check if there's an internet connection, and if there is, send photos to the server which are not already saved in the server? Is there an easier way?

After looking into the method for uploading the photo, I noticed that the post call isn't asynchronous. If this is done in the UI thread it could slow down your app.

Sorry this isn't an answer, don't have the reputation to comment

Or the only way to do it, is just save it to the external storage, and when user opens my application, check if there's an internet connection, and if there is, send photos to the server which are not already saved in the server?

That's more or less correct. You could enable a formerly-disabled manifest-registered BroadcastReceiver to listen for connectivity changes, so once you have a connection, you can automatically try the upload. That is more work, but it gets the photo to the server faster.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM