How to properly handle intents?
My application can view files of a certain type, and declares this in an intent-filter in its AndroidManifest.xml. My app launches fine, but I see some inconsistent behavior on different devices and different applications and am wondering if there is a best practice I am missing.
I often see this use case on some file browsers:
Other times I see this more desirable use case:
So, I wonder if this inconsistent is due to different implementations by the file browsers, or if there is something I should be doing to properly handle intents, like some way of "releasing" the application that launched my app?
I think your problem is not handling intents, but handling the activity stack. You can explicitly finish() your 'launcher' activity (as classified in the AndroidManifest.xml). You can also 'put' a vflag in your filebrowser intent which indicates as to when the app should follow what sequence of activities. For eg., if you want the filebrowser to start directly, you could search the intent for that flag and depending upon its value finish() the launcher activity and start the filebrowser actvitiy directly OR continue as per your original sequence of activities.
链接地址: http://www.djcxy.com/p/41880.html下一篇: 如何正确处理意图?