From which SDK level is android.intent.action.SIM_STATE_CHANGED broadcast intent supported?

﹥>﹥吖頭↗ 提交于 2019-12-12 04:44:53

问题


I have an app in the market (SIM Locked Notifier) that relies on a broadcast receiver that reacts upon receiving a broadcast intent for *android.intent.action.SIM_STATE_CHANGED*.. I developed the app for the latest version, 4.0.3 (i.e. SDK level 15) and now I'd like to extend its compatibility to lower levels (providing runtime checks for unavailable things, like action bar or preference fragments)... The problem is that I'd like to understand if the *SIM_STATE_CHANGED* event is generated also on older platforms.. This intent is undocumented, it is not even found within the *platforms/android-15/data/broadcast_actions.txt* within the SDK.. Should I dig into the sources to understand where it is implemented and down to which SDK level? Is this a vendor-specific event? I have an HTC One X on which it works.


回答1:


I am not sure about your first question.But i can help you out in answering Second question.

and now I'd like to extend its compatibility to lower levels (providing runtime checks for unavailable things, like action bar or preference fragments)

Reflection will help you out in this case. Using reflection you can query class for available methods,constructors etc.

Suppose you want to use PopupMenu in your application.And it may be the case that you application still want to run on pre 4.0 devices.So use reflection

Following code snippet and bit of Google search will help you out.

String sClassName = "android.widget.PopupMenu";  
    try {  
        Class classToInvestigate = Class.forName(sClassName);   
        Yes!!! Class is aviliable now do whatever you want to do with PopupMenu.
        // Dynamically do stuff with this class  
        // List constructors, fields, methods, etc.  

    } catch (ClassNotFoundException e) {  
        // Class not found!  
        it means application is running on pre 4.0 version device.
    } catch (Exception e) {  
        // Unknown exception  
    }  


来源:https://stackoverflow.com/questions/10861340/from-which-sdk-level-is-android-intent-action-sim-state-changed-broadcast-intent

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!