广播监听系统切换语言变换
来源:互联网 发布:网络炒作公司价格 编辑:程序博客网 时间:2024/05/18 01:38
广播监听系统切换语言变换
静态注册:
<receiver
android:name="com.ulucu.receiver.LOCALEReceiver"
android:enabled="true">
<intent-filter>
<action android:name="android.intent.action.LOCALE_CHANGED" />
</intent-filter>
</receiver>
public class LOCALEReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(Intent.ACTION_LOCALE_CHANGED)) {
Intent it = new Intent(context, StartActivity.class);
it.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
it.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
context.startActivity(it);
}
}
}
动态注册:
privateBroadcastReceiver mReceiver = new BroadcastReceiver(){
@Override
publicvoid onReceive(Context context, Intent intent) {
Log.v(TAG, "mReceiver onReceive intent.getAction(): "+intent.getAction());
if(intent.getAction().equals(Intent.ACTION_LOCALE_CHANGED)) {
…//此处做你的处理
}
}
};
IntentFilter filter =newIntentFilter();
filter.addAction(Intent.ACTION_LOCALE_CHANGED);
mContext.registerReceiver(mReceiver, filter);
静态注册:
<receiver
android:name="com.ulucu.receiver.LOCALEReceiver"
android:enabled="true">
<intent-filter>
<action android:name="android.intent.action.LOCALE_CHANGED" />
</intent-filter>
</receiver>
public class LOCALEReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(Intent.ACTION_LOCALE_CHANGED)) {
Intent it = new Intent(context, StartActivity.class);
it.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
it.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
context.startActivity(it);
}
}
}
动态注册:
privateBroadcastReceiver mReceiver = new BroadcastReceiver(){
@Override
publicvoid onReceive(Context context, Intent intent) {
Log.v(TAG, "mReceiver onReceive intent.getAction(): "+intent.getAction());
if(intent.getAction().equals(Intent.ACTION_LOCALE_CHANGED)) {
…//此处做你的处理
}
}
};
IntentFilter filter =newIntentFilter();
filter.addAction(Intent.ACTION_LOCALE_CHANGED);
mContext.registerReceiver(mReceiver, filter);
0 0
- 广播监听系统切换语言变换
- 广播监听系统切换语言变换
- Android 系统语言切换监听和设置
- 监听系统广播Action
- android 使用广播监听网络切换
- Android利用系统广播---监听网络变化
- 监听系统开机广播并启动Activity
- 从监听系统启动开始学习系统广播
- 监听系统wifi、蓝牙变化广播
- 接收系统广播监听网络变化
- Android广播——监听系统状态
- 常用的监听系统广播接收器
- Android系统广播实现短信监听
- Android系统广播实现短信监听
- Android监听系统广播 和自定义广播遇到的问题
- linux系统语言切换
- Matlab2014切换系统语言
- Android 系统语言切换
- WebView下载文件
- Qt5.8 + VS2015 环境搭建
- Spring-cloud Eureka 集群
- 隐藏自己的小秘密
- 1.5 网页下载器与urllib2模块(核心)
- 广播监听系统切换语言变换
- 去除UITabBar底部的一条线
- LTspice introduction
- 转载:stm32 数据类型的定义(常用的U8,U16,U32到底代表什么)
- 2017实习生面试经历
- 多种数据库添加自增主键
- stdafx.h的作用
- Evaluate Division
- Mac下同时安装切换多个版本的JDK