Android如何接收locale改变的消息 || locale改变后,发送什么消息

       locale信息改变之后,会发广播消息Intent.ACTION_LOCALE_CHANGED,

具体实现在activitymanagerservice.java代码updateConfigurationLocked函数中,

       自己写接收代码如下:

       接收代码:

public class testReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        Log.v("test", "hello");

        if(intent.getAction().compareTo(Intent.ACTION_LOCALE_CHANGED) == 0)
        {
            //处理

            Log.v("test", “received ACTION_LOCALE_CHANGED”);
        }       
    }
}

 

      在AndroidManifest.xml中,添加intent过滤器,声明可以接收广播消息,

      如下,

             

            

      

       这样当locale改变之后,onReceive会接收到locale改变的消息,执行相应的处理

你可能感兴趣的:(android研发)