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
    
    
    Unfortunately, %1$s has stopped.
    
    Unfortunately, the process %1$s has
        stopped.
    
    
    OK

frameworks/base/core/res/res/values-fa/strings.xml

    
    "ﻢﺗﺄﺴﻓﺎﻨﻫ، %1$s ﻢﺗﻮﻘﻓ ﺵﺪﻫ ﺎﺴﺗ."
    "ﻢﺗﺄﺴﻓﺎﻨﻫ، پﺭﺩﺍﺰﺷ %1$s ﻢﺗﻮﻘﻓ ﺵﺪﻫ ﺎﺴﺗ."
    
    "ﺕﺃییﺩ"

三、系统多国语言支持

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多国语言)