Finding out if an intent is available
Sometimes you want to find if an application has registered for a certain intent. For example you want to check if a certain receiver is available and if you enable some functionality in your app.
某些時候你想要知道某個AP是否有註冊了一個明確的intent,比如說你想要檢查某個receiver是否存在,然後根據是否存在來這個receiver來在你的AP裡面enable某些功能
This can be done via checking the PackageManager. The following code checks if an intent exists. You can check via this method for intent and change your application behavior accordingly for example disable or hide menu items.
我們可以通過PackageManager來check它,下面的代碼檢測了一個intent是否存在.
引用:http://blog.csdn.net/kesenhoo/article/details/7321944
翻譯自; http://www.vogella.de/articles/AndroidIntent/article.html
沒有留言:
張貼留言