unfortunately XXX has stopped多国语言
2015-11-30 16:50
267 查看
错误提示框的弹出:
frameworks/base/core/java/com/android/internal/os/RuntimeInit.java
public static final void main(String[] argv) {
commonInit();
}
private static final void commonInit() {
Thread.setDefaultUncaughtExceptionHandler(new UncaughtHandler());
}
private static class UncaughtHandler implements Thread.UncaughtExceptionHandler {
public void uncaughtException(Thread t, Throwable e) {
ActivityManagerNative.getDefault().handleApplicationCrash(mApplicationObject, new ApplicationErrorReport.CrashInfo(e));
Process.killProcess(Process.myPid());
System.exit(10);
}frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
一、Dialog位置
frameworks/base/services/core/java/com/android/server/am/AppErrorDialog.java
out/target/common/R/com/android/internal/R.java
二、多国语言
frameworks/base/core/res/res/values/strings.xml
frameworks/base/core/res/res/values-fa/strings.xml
三、系统多国语言支持
device/mtk/mtk/products/generic.mk
四、应用程序
frameworks/base/core/java/com/android/internal/os/RuntimeInit.java
public static final void main(String[] argv) {
commonInit();
}
private static final void commonInit() {
Thread.setDefaultUncaughtExceptionHandler(new UncaughtHandler());
}
private static class UncaughtHandler implements Thread.UncaughtExceptionHandler {
public void uncaughtException(Thread t, Throwable e) {
ActivityManagerNative.getDefault().handleApplicationCrash(mApplicationObject, new ApplicationErrorReport.CrashInfo(e));
Process.killProcess(Process.myPid());
System.exit(10);
}frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
public void handleApplicationCrash(IBinder app, ApplicationErrorReport.CrashInfo crashInfo) { handleApplicationCrashInner("crash", r, processName, crashInfo); } void handleApplicationCrashInner(String eventType, ProcessRecord r, String processName, ApplicationErrorReport.CrashInfo crashInfo) { crashApplication(r, crashInfo); } private void crashApplication(ProcessRecord r, ApplicationErrorReport.CrashInfo crashInfo) { msg.what = SHOW_ERROR_MSG; HashMap data = new HashMap(); data.put("result", result); data.put("app", r); msg.obj = data; mHandler.sendMessage(msg); } public void handleMessage(Message msg) { switch (msg.what) { case SHOW_ERROR_MSG: { Dialog d = new AppErrorDialog(mContext,ActivityManagerService.this, res, proc); d.show(); } } }
一、Dialog位置
frameworks/base/services/core/java/com/android/server/am/AppErrorDialog.java
public AppErrorDialog(Context context, ActivityManagerService service, AppErrorResult result, ProcessRecord app) { setTitle(res.getText(com.android.internal.R.string.aerr_title)); setButton(DialogInterface.BUTTON_POSITIVE, res.getText(com.android.internal.R.string.force_close), mHandler.obtainMessage(FORCE_QUIT)); }
out/target/common/R/com/android/internal/R.java
public static final int force_close=0x01040478;
二、多国语言
frameworks/base/core/res/res/values/strings.xml
<string name="aerr_title"></string> <!-- Text of the alert that is displayed when an application has crashed. --> <string name="aerr_application">Unfortunately, <xliff:g id="application">%1$s</xliff:g> has stopped.</string> <!-- Text of the alert that is displayed when an application has crashed. --> <string name="aerr_process">Unfortunately, the process <xliff:g id="process">%1$s</xliff:g> has stopped.</string> <!-- Title of the alert when an application is not responding. --> <string name="anr_title"></string> <string name="force_close">OK</string>
frameworks/base/core/res/res/values-fa/strings.xml
<string name="aerr_title" msgid="1905800560317137752"></string> <string name="aerr_application" msgid="932628488013092776">"ﻢﺗﺄﺴﻓﺎﻨﻫ، <xliff:g id="APPLICATION">%1$s</xliff:g> ﻢﺗﻮﻘﻓ ﺵﺪﻫ ﺎﺴﺗ."</string> <string name="aerr_process" msgid="4507058997035697579">"ﻢﺗﺄﺴﻓﺎﻨﻫ، پﺭﺩﺍﺰﺷ <xliff:g id="PROCESS">%1$s</xliff:g> ﻢﺗﻮﻘﻓ ﺵﺪﻫ ﺎﺴﺗ."</string> <string name="anr_title" msgid="4351948481459135709"></string> <string name="force_close" msgid="8346072094521265605">"ﺕﺃییﺩ"</string>
三、系统多国语言支持
device/mtk/mtk/products/generic.mk
PRODUCT_LOCALES = \ zh_CN \ en_US \ ldpi \ fa \ fa_IR PRODUCT_PROPERTY_OVERRIDES += persist.sys.language=en PRODUCT_PROPERTY_OVERRIDES += persist.sys.country=AU
四、应用程序
IActivityManager am = ActivityManagerNative.getDefault(); try { Configuration config = am.getConfiguration(); config.locale = new Locale("fa"/*,"IR"*/); config.userSetLocale = true; am.updateConfiguration(config); }catch (Exception e) { Log.d("TKTK","call error"); }
相关文章推荐
- powershell启用脚本
- Linux串口编程
- 使用PropertyChangeSupport监听变量变化
- nginx url rewrite之thinkphp示例
- 查看LINUX进程内存占用情况
- Linux权限解释
- Centos下《LVM扩展目录空间 及命令介绍》
- 关于java,tomcat连接mySql数据库
- [Linux] Wireshark 抓到超过(大于) MTU 的封包
- Opencv中的DMatch
- SHELL编程入门(二)---SHELL循环与条件
- OpenCv学习笔记(二)—cv::Mat学习
- OpenCv学习笔记(一)——数字图形的基础和结构
- 本地代码调用远程shell代码
- 使用Navicat连接管理远程linux服务器上的mysql数据库
- 学习的网站(视频)
- nginx的高级配置(1)——为某个虚拟主机添加用户验证
- centos5下面yum安装squid
- 4412开发板Android和LinuxQT烧写方法
- Linux下防火墙开启相关端口及查看已开启端口