unfortunately XXX has stopped多国语言

错误提示框的弹出:

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");
  }


你可能感兴趣的:(unfortunately XXX has stopped多国语言)