List of usage examples for java.util Locale JAPANESE
Locale JAPANESE
To view the source code for java.util Locale JAPANESE.
Click Source Link
From source file:org.terasoluna.gfw.common.codelist.i18n.SimpleI18nCodeListTest.java
@Test public void testSetColumns01() { assertThat(testSetColumns01.codeListTable.size(), is(14)); // 2 rows x 7 // columns Map<String, String> row1 = testSetColumns01.asMap(Locale.ENGLISH); assertThat(row1, is(notNullValue())); assertThat(row1.keySet().toString(), is("[0, 1, 2, 3, 4, 5, 6]")); // check // order assertThat(row1.get("0"), is("Sun.")); assertThat(row1.get("1"), is("Mon.")); assertThat(row1.get("2"), is("Tue.")); assertThat(row1.get("3"), is("Wed.")); assertThat(row1.get("4"), is("Thu.")); assertThat(row1.get("5"), is("Fri.")); assertThat(row1.get("6"), is("Sat.")); Map<String, String> row2 = testSetColumns01.asMap(Locale.JAPANESE); assertThat(row2, is(notNullValue())); assertThat(row2.keySet().toString(), is("[0, 1, 2, 3, 4, 5, 6]")); // check // order assertThat(row2.get("0"), is("")); assertThat(row2.get("1"), is("")); assertThat(row2.get("2"), is("?")); assertThat(row2.get("3"), is("")); assertThat(row2.get("4"), is("")); assertThat(row2.get("5"), is("")); assertThat(row2.get("6"), is("")); }
From source file:com.clustercontrol.notify.util.NotifyUtil.java
/** * ?????//w ww.j ava2s. c o m * @param outputInfo * @param notifyInfo * @return ?? */ public static Map<String, String> createParameter(OutputBasicInfo outputInfo, NotifyInfo notifyInfo) { Map<String, String> param = null; SimpleDateFormat sdf = null; param = new HashMap<String, String>(); if (outputInfo != null) { // Locale locale = getNotifyLocale(); /** */ String subjectDateFormat = HinemosPropertyUtil.getHinemosPropertyStr("notify.date.format", SUBJECT_DATE_FORMAT_DEFAULT); if (log.isDebugEnabled()) { log.debug("TextReplacer.static SUBJECT_DATE_FORMAT = " + subjectDateFormat); } sdf = new SimpleDateFormat(subjectDateFormat); sdf.setTimeZone(HinemosTime.getTimeZone()); param.put(_KEY_PRIORITY_NUM, String.valueOf(outputInfo.getPriority())); if (Messages.getString(PriorityConstant.typeToMessageCode(outputInfo.getPriority()), locale) != null) { param.put(_KEY_PRIORITY, Messages.getString(PriorityConstant.typeToMessageCode(outputInfo.getPriority()), locale)); } else { param.put(_KEY_PRIORITY, null); } if (Messages.getString(PriorityConstant.typeToMessageCode(outputInfo.getPriority()), Locale.JAPANESE) != null) { param.put(_KEY_PRIORITY_JP, Messages .getString(PriorityConstant.typeToMessageCode(outputInfo.getPriority()), Locale.JAPANESE)); } else { param.put(_KEY_PRIORITY_JP, null); } if (Messages.getString(PriorityConstant.typeToMessageCode(outputInfo.getPriority()), Locale.ENGLISH) != null) { param.put(_KEY_PRIORITY_EN, Messages .getString(PriorityConstant.typeToMessageCode(outputInfo.getPriority()), Locale.ENGLISH)); } else { param.put(_KEY_PRIORITY_EN, null); } String pluginId = outputInfo.getPluginId(); param.put(_KEY_PLUGIN_ID, pluginId); param.put(_KEY_PLUGIN_NAME, Messages.getString(HinemosModuleConstant.nameToMessageCode(pluginId), locale)); String monitorId = outputInfo.getMonitorId(); param.put(_KEY_MONITOR_ID, outputInfo.getMonitorId()); if (monitorId != null && pluginId != null && pluginId.startsWith("MON_")) { MonitorSettingControllerBean controller = new MonitorSettingControllerBean(); try { MonitorInfo monitorInfo = controller.getMonitor(monitorId); param.put(_KEY_MONITOR_DESCRIPTION, monitorInfo.getDescription()); param.put(_KEY_CALENDAR_ID, monitorInfo.getCalendarId()); param.put(_KEY_MONITOR_OWNER_ROLE_ID, monitorInfo.getOwnerRoleId()); } catch (MonitorNotFound e) { log.debug("createParameter() : monitor not found. " + e.getMessage()); } catch (HinemosUnknown e) { log.debug("createParameter() : HinemosUnknown. " + e.getMessage()); } catch (InvalidRole e) { log.debug("createParameter() : InvalidRole. " + e.getMessage()); } } else { param.put(_KEY_MONITOR_DESCRIPTION, ""); param.put(_KEY_CALENDAR_ID, ""); param.put(_KEY_MONITOR_OWNER_ROLE_ID, ""); } param.put(_KEY_MONITOR_DETAIL_ID, outputInfo.getSubKey()); param.put(_KEY_FACILITY_ID, outputInfo.getFacilityId()); param.put(_KEY_SCOPE, HinemosMessage.replace(outputInfo.getScopeText(), locale)); if (outputInfo.getGenerationDate() != null) { param.put(_KEY_GENERATION_DATE, sdf.format(outputInfo.getGenerationDate())); } else { param.put(_KEY_GENERATION_DATE, null); } param.put(_KEY_APPLICATION, HinemosMessage.replace(outputInfo.getApplication(), locale)); param.put(_KEY_MESSAGE, HinemosMessage.replace(outputInfo.getMessage(), locale)); param.put(_KEY_ORG_MESSAGE, HinemosMessage.replace(outputInfo.getMessageOrg(), locale)); List<String> jobFacilityIdList = outputInfo.getJobFacilityId(); List<String> jobMessageList = outputInfo.getJobMessage(); if (jobFacilityIdList != null) { for (int i = 0; i < jobFacilityIdList.size(); ++i) { String key = _KEY_JOB_MESSAGE + jobFacilityIdList.get(i); String value = HinemosMessage.replace(jobMessageList.get(i), locale); param.put(key, value); log.debug("NotifyUtil.createParameter >>> param.put = : " + key + " value = " + value); } } if (outputInfo.getFacilityId() != null) { try { RepositoryControllerBean repositoryCtrl = new RepositoryControllerBean(); FacilityInfo facility = repositoryCtrl.getFacilityEntityByPK(outputInfo.getFacilityId()); param.put(_KEY_FACILITY_NAME, HinemosMessage.replace(facility.getFacilityName(), locale)); if (FacilityUtil.isNode(facility)) { NodeInfo nodeInfo = repositoryCtrl.getNode(outputInfo.getFacilityId()); Map<String, String> variable = RepositoryUtil.createNodeParameter(nodeInfo); param.putAll(variable); } } catch (FacilityNotFound e) { log.debug("createParameter() : facility not found. " + e.getMessage()); } catch (InvalidRole e) { log.debug("createParameter() : InvalidRole. " + e.getMessage()); } catch (HinemosUnknown e) { log.debug("createParameter() : HinemosUnknown. " + e.getMessage()); } catch (Exception e) { log.warn("facility not found. (" + outputInfo.getFacilityId() + ") : " + e.getClass().getSimpleName() + ", " + e.getMessage(), e); } } if (outputInfo.getJobApprovalText() != null) { param.put(_KEY_JOB_APPROVAL_TEXT, HinemosMessage.replace(outputInfo.getJobApprovalText())); log.info("_KEY_JOB_APPROVAL_TEXT" + outputInfo.getJobApprovalText()); } if (outputInfo.getJobApprovalText() != null) { param.put(_KEY_JOB_APPROVAL_MAIL, HinemosMessage.replace(outputInfo.getJobApprovalMail())); log.info("_KEY_JOB_APPROVAL_MAIL" + outputInfo.getJobApprovalMail()); } } if (notifyInfo != null) { param.put(_KEY_NOTIFY_ID, String.valueOf(notifyInfo.getNotifyId())); param.put(_KEY_NOTIFY_DESCRIPTION, notifyInfo.getDescription()); } if (log.isTraceEnabled()) { for (Map.Entry<String, String> entry : param.entrySet()) { log.trace("createParameter() : param[" + entry.getKey() + "]=" + entry.getValue()); } } return param; }
From source file:com.yojiokisoft.yumekanow.fragment.SleepFragment.java
/** * ?/*w w w . jav a2 s . c o m*/ */ @Click(R.id.setTimerButton) /*package*/void setTimerButtonClicked() { // ? MyAlarmManager.cancelStartTimer(mActivity); // ? int hour = mWakeUpTime.getCurrentHour(); int min = mWakeUpTime.getCurrentMinute(); Calendar calendar = Calendar.getInstance(); // Calendar? calendar.setTimeInMillis(System.currentTimeMillis()); // ?? if (mTimeKind.getCheckedRadioButtonId() == R.id.jikan) { // if (hour < calendar.get(Calendar.HOUR_OF_DAY) || (hour <= calendar.get(Calendar.HOUR_OF_DAY) && min < calendar.get(Calendar.MINUTE))) { calendar.add(Calendar.DAY_OF_MONTH, 1); } calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH), hour, min, 0); } else { // calendar.add(Calendar.MINUTE, 60 * hour + min); // ? + } MyAlarmManager.setWakuUpTimer(mActivity, calendar.getTimeInMillis()); Toast toast = Toast.makeText(mActivity, getString(R.string.good_night), Toast.LENGTH_LONG); toast.show(); try { ((MainActivity) mActivity).closeActivity(); } catch (RuntimeException e) { throw new RuntimeException("activity ? closeActivity ?????."); } // ??????? SettingDao settingDao = SettingDao.getInstance(); String time = String.format(Locale.JAPANESE, "%02d%02d", hour, min); if (mTimeKind.getCheckedRadioButtonId() == R.id.jikan) { settingDao.setSleepJikan(time); } else { settingDao.setSleepTimer(time); } }
From source file:jp.terasoluna.fw.web.struts.form.FieldChecksExTest09.java
/** * testValidateDateRange01()//from w ww . java2s . c om * <br><br> * * (??n) * <br> * _?FC,F * <br><br> * l?F(?) bean:null<br> * (?) va:not null<br> * (?) field:not null<br> * Msg("message","message")<br> * (?) errors:not null<br> * (vf)<br> * (?) validator:not null<br> * (?) request:not null<br> * Locale=JAPANESE<br> * * <br> * l?F(l) boolean:true<br> * (?) ?O:?Ox?F<br> * G?[<br> * ?bZ?[W?F<br> * bean is null.<br> * (?) errors:not null<br> * (vf)<br> * * <br> * ?beannull?AG?[?O?otruep * mF?B * <br> * * @throws Exception ?\bh?O */ public void testValidateDateRange01() throws Exception { //eXgf?[^? // ++++ beanIuWFNg ++++ String bean = null; // ++++ ??IuWFNg ValidatorAction va = new ValidatorAction(); // ++++ ?tB?[h? Field field = new Field(); // ?bZ?[W? Msg msg = new Msg(); msg.setKey("message"); msg.setName("message"); msg.setResource(false); field.addMsg(msg); // G?[? ActionMessages errors = new ActionMessages(); // [HTTPNGXg MockHttpServletRequest request = new MockHttpServletRequest(); request.setLocale(Locale.JAPANESE); // ValidatorResourcesCX^X ValidatorResources validatorResources = new ValidatorResources(); // ValidatorCX^X Validator validator = new Validator(validatorResources); // eXg?s boolean result = FieldChecksEx.validateDateRange(bean, va, field, errors, validator, request); // eXgmF // truep?B assertTrue(result); // G?[??B assertTrue(errors.isEmpty()); // G?[?OmF assertTrue(LogUTUtil.checkError("bean is null.")); }
From source file:org.talend.designer.core.ui.preferences.I18nPreferencePage.java
@Override protected void createFieldEditors() { // Adds a combo for language selection. String spanish = "Espa\u00F1ol"; //$NON-NLS-1$ byte[] utf8Bytes; try {/* ww w . j av a2s . com*/ utf8Bytes = spanish.getBytes("UTF8"); //$NON-NLS-1$ spanish = new String(utf8Bytes, "UTF8"); //$NON-NLS-1$ } catch (UnsupportedEncodingException e1) { // could be translated, but it's only in case of error when change UTF8 characters. spanish = "Spanish"; //$NON-NLS-1$ } String russian = "\u0420\u0443\u0441\u0441\u043A\u0438\u0439"; //$NON-NLS-1$ try { utf8Bytes = russian.getBytes("UTF8"); //$NON-NLS-1$ russian = new String(utf8Bytes, "UTF8"); //$NON-NLS-1$ } catch (UnsupportedEncodingException e1) { // could be translated, but it's only in case of error when change UTF8 characters. russian = "Russian"; //$NON-NLS-1$ } String greek = "\u0395\u03bb\u03bb\u03b7\u03bd\u03b9\u03ba\u03ac"; //$NON-NLS-1$ try { utf8Bytes = greek.getBytes("UTF8"); //$NON-NLS-1$ greek = new String(utf8Bytes, "UTF8"); //$NON-NLS-1$ } catch (UnsupportedEncodingException e1) { // could be translated, but it's only in case of error when change UTF8 characters. greek = "Greek"; //$NON-NLS-1$ } String arabic = "\u0627\u0644\u0639\u0631\u0628\u064a\u0647"; //$NON-NLS-1$ try { utf8Bytes = arabic.getBytes("UTF8"); //$NON-NLS-1$ arabic = new String(utf8Bytes, "UTF8"); //$NON-NLS-1$ } catch (UnsupportedEncodingException e1) { // could be translated, but it's only in case of error when change UTF8 characters. arabic = "Arabic"; //$NON-NLS-1$ } String serbian = "\u0421\u0440\u043f\u0441\u043a\u0438"; //$NON-NLS-1$ try { utf8Bytes = serbian.getBytes("UTF8"); //$NON-NLS-1$ serbian = new String(utf8Bytes, "UTF8"); //$NON-NLS-1$ } catch (UnsupportedEncodingException e1) { // could be translated, but it's only in case of error when change UTF8 characters. serbian = "Serbian"; //$NON-NLS-1$ } String[][] entryNamesAndValues = { { Locale.ENGLISH.getDisplayLanguage(Locale.ENGLISH), Locale.ENGLISH.getLanguage() }, { Locale.FRENCH.getDisplayLanguage(Locale.FRENCH), Locale.FRENCH.getLanguage() }, { Locale.CHINESE.getDisplayLanguage(Locale.CHINESE), "zh_CN" }, { Locale.GERMAN.getDisplayLanguage(Locale.GERMAN), Locale.GERMAN.getLanguage() }, { Locale.JAPANESE.getDisplayLanguage(Locale.JAPANESE), Locale.JAPANESE.getLanguage() }, { Locale.ITALIAN.getDisplayLanguage(Locale.ITALIAN), Locale.ITALIAN.getLanguage() }, { "Brasil", "pt_BR" }, //$NON-NLS-1$ //$NON-NLS-2$ { spanish, "es" }, { russian, "ru" }, //$NON-NLS-1$ //$NON-NLS-2$ { Locale.KOREA.getDisplayLanguage(Locale.KOREA), "kr" }, { "Turkish", "tr" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ { greek, "el" }, { "Hrvatski", "hr" }, { arabic, "ar" }, { serbian, "sr" }, { "Polski", "pl" }, { "Romanian", "ro" }, { "Netherlands", "nl" } }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ // /$NON-NLS-7$ languageSelectionEditor = new OneLineComboFieldEditor(ITalendCorePrefConstants.LANGUAGE_SELECTOR, Messages.getString("I18nPreferencePage.needRestart"), entryNamesAndValues, getFieldEditorParent()); //$NON-NLS-1$ addField(languageSelectionEditor); Composite composite = getFieldEditorParent(); LabelFieldEditor importAll = new LabelFieldEditor( Messages.getString("I18nPreferencePage.translationInformation"), //$NON-NLS-1$ composite); addField(importAll); Button allUpdate = new Button(composite, SWT.FLAT); allUpdate.setText(Messages.getString("I18nPreferencePage.importBabili")); //$NON-NLS-1$ allUpdate.setLayoutData(new GridData()); allUpdate.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(SelectionEvent e) { // import all update from Babili // select the .zip file FileDialog fd = new FileDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), SWT.OPEN); fd.setText("Open"); //$NON-NLS-1$ fd.setFilterPath("C:" + fs); //$NON-NLS-1$ String[] filterExtensions = { "*.zip" }; //$NON-NLS-1$ fd.setFilterExtensions(filterExtensions); String selected = fd.open(); if (selected != null) { isBabiliButtonClicked = true; runProgressMonitorDialog(selected); if (MessageDialog.openConfirm(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), Messages.getString("I18nPreferencePage.restart"), //$NON-NLS-1$ Messages.getString("I18nPreferencePage.restartButton"))) { PlatformUI.getWorkbench().restart(); } } } @Override public void widgetDefaultSelected(SelectionEvent e) { // Nothing to do } }); // added by nma Button restoredefault = new Button(composite, SWT.FLAT); restoredefault.setText("Restore Defaults"); //$NON-NLS-1$ restoredefault.setLayoutData(new GridData()); restoredefault.addSelectionListener(new SelectionListener() { @Override public void widgetDefaultSelected(SelectionEvent e) { // Nothing to do } @Override public void widgetSelected(SelectionEvent e) { isBabiliButtonClicked = true; runProgressMonitorDialog(Messages.getString("I18nPreferencePage.restoreDefault")); //$NON-NLS-1$ if (MessageDialog.openConfirm(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), Messages.getString("I18nPreferencePage.restart"), Messages.getString("I18nPreferencePage.restartButton"))) { PlatformUI.getWorkbench().restart(); } } }); }
From source file:divya.myvision.TessActivity.java
public void setLang(String lang) { Locale locale;/*from w w w . j a va 2 s. c om*/ if (lang.equals("Spanish")) { // Set up the Text To Speech engine. TextToSpeech.OnInitListener listener = new TextToSpeech.OnInitListener() { @Override public void onInit(final int status) { Locale locSpanish = new Locale("spa", "MEX"); tts.setLanguage(locSpanish); } }; tts = new TextToSpeech(this.getApplicationContext(), listener); locale = new Locale("spa", "MEX"); } else if (lang.equals("French")) { // Set up the Text To Speech engine. TextToSpeech.OnInitListener listener = new TextToSpeech.OnInitListener() { @Override public void onInit(final int status) { tts.setLanguage(Locale.FRENCH); } }; tts = new TextToSpeech(this.getApplicationContext(), listener); locale = new Locale("fr"); } else if (lang.equals("Japanese")) { // Set up the Text To Speech engine. TextToSpeech.OnInitListener listener = new TextToSpeech.OnInitListener() { @Override public void onInit(final int status) { tts.setLanguage(Locale.JAPANESE); } }; tts = new TextToSpeech(this.getApplicationContext(), listener); locale = new Locale("ja"); } else if (lang.equals("Chinese")) { // Set up the Text To Speech engine. TextToSpeech.OnInitListener listener = new TextToSpeech.OnInitListener() { @Override public void onInit(final int status) { tts.setLanguage(Locale.CHINESE); } }; tts = new TextToSpeech(this.getApplicationContext(), listener); locale = new Locale("zh"); } else if (lang.equals("German")) { // Set up the Text To Speech engine. TextToSpeech.OnInitListener listener = new TextToSpeech.OnInitListener() { @Override public void onInit(final int status) { tts.setLanguage(Locale.GERMAN); } }; tts = new TextToSpeech(this.getApplicationContext(), listener); locale = new Locale("de"); } else if (lang.equals("Italian")) { // Set up the Text To Speech engine. TextToSpeech.OnInitListener listener = new TextToSpeech.OnInitListener() { @Override public void onInit(final int status) { tts.setLanguage(Locale.ITALIAN); } }; tts = new TextToSpeech(this.getApplicationContext(), listener); locale = new Locale("it"); } else if (lang.equals("Korean")) { // Set up the Text To Speech engine. TextToSpeech.OnInitListener listener = new TextToSpeech.OnInitListener() { @Override public void onInit(final int status) { tts.setLanguage(Locale.KOREAN); } }; tts = new TextToSpeech(this.getApplicationContext(), listener); locale = new Locale("ko"); } else if (lang.equals("Hindi")) { // Set up the Text To Speech engine. TextToSpeech.OnInitListener listener = new TextToSpeech.OnInitListener() { @Override public void onInit(final int status) { Locale locHindhi = new Locale("hi"); tts.setLanguage(locHindhi); } }; tts = new TextToSpeech(this.getApplicationContext(), listener); locale = new Locale("hi"); } else if (lang.equals("Russian")) { // Set up the Text To Speech engine. TextToSpeech.OnInitListener listener = new TextToSpeech.OnInitListener() { @Override public void onInit(final int status) { Locale locHindhi = new Locale("ru"); tts.setLanguage(locHindhi); } }; tts = new TextToSpeech(this.getApplicationContext(), listener); locale = new Locale("ru"); } else { TextToSpeech.OnInitListener listener = new TextToSpeech.OnInitListener() { @Override public void onInit(final int status) { tts.setLanguage(Locale.US); } }; tts = new TextToSpeech(this.getApplicationContext(), listener); locale = new Locale("en"); } Locale.setDefault(locale); Configuration config = new Configuration(); config.setLocale(locale); this.getApplicationContext().getResources().updateConfiguration(config, null); }
From source file:net.e_fas.oss.tabijiman.MapsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { e_print("onCreate"); // ActionBar? if (savedInstanceState == null) { // customActionBar?? View customActionBarView = this.getActionBarView(); // ActionBar?? ActionBar actionBar = this.getSupportActionBar(); // ?????('<' <- ???) if (actionBar != null) { // ??????? actionBar.setDisplayShowTitleEnabled(false); // icon??????? actionBar.setDisplayShowHomeEnabled(false); // ActionBar?customView? actionBar.setCustomView(customActionBarView); // CutomView?? actionBar.setDisplayShowCustomEnabled(true); }/*from www .j a v a2 s . c om*/ } // ????? Locale locale = Locale.getDefault(); if (locale.equals(Locale.JAPAN) || locale.equals(Locale.JAPANESE)) { locale = Locale.JAPAN; } else { locale = Locale.ENGLISH; } // ?? Locale.setDefault(locale); Configuration config = new Configuration(); // Resources?? config.locale = locale; Resources resources = getBaseContext().getResources(); // Resources?????? resources.updateConfiguration(config, null); super.onCreate(savedInstanceState); setContentView(R.layout.activity_maps); try { new CreateInitData(this).exec(locale); new SPARQL().query(AppSetting.query_place, "place"); new SPARQL().query(AppSetting.query_frame, "frame"); } catch (IOException | JSONException e) { e.printStackTrace(); } makeTempDir(); // ??? ConnectivityManager connMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connMgr.getActiveNetworkInfo(); if (networkInfo == null) { Toast.makeText(getApplicationContext(), "???????????", Toast.LENGTH_LONG).show(); } buttons = new ArrayList<>(); View.OnClickListener change_button = new View.OnClickListener() { @Override public void onClick(View v) { CameraPosition cameraPos; if (v == TrainButton) { zoomLevel = 9.0f; cameraPos = new CameraPosition.Builder() .target(new LatLng(nowLocation.latitude, nowLocation.longitude)).zoom(zoomLevel) .bearing(0).build(); } else if (v == CarButton) { zoomLevel = 11.0f; cameraPos = new CameraPosition.Builder() .target(new LatLng(nowLocation.latitude, nowLocation.longitude)).zoom(zoomLevel) .bearing(0).build(); } else { zoomLevel = 14.0f; cameraPos = new CameraPosition.Builder() .target(new LatLng(nowLocation.latitude, nowLocation.longitude)).zoom(zoomLevel) .bearing(0).build(); } if (!v.isActivated()) { v.setActivated(true); for (int i = 0; i < buttons.size(); i++) { if (buttons.get(i) != v) { buttons.get(i).setActivated(false); } } } mMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPos)); } }; View.OnClickListener marker_change_button = new View.OnClickListener() { @Override public void onClick(View v) { if (!v.isActivated()) { v.setActivated(true); if (v == FrameSwitch) { setMarker("frame"); FrameMarkerOptions.clear(); } else { setMarker("place"); PlaceMarkerOptions.clear(); } } else { v.setActivated(false); if (v == FrameSwitch) { for (Marker m : FrameMarker) { m.remove(); } FrameMarker.clear(); } else { for (Marker m : PlaceMarker) { m.remove(); } PlaceMarker.clear(); } } } }; // LocationManager? mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); TakePicture = (ImageButton) findViewById(R.id.takePicture); TakePicture.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent TakePictureView = new Intent(getApplicationContext(), TakePicture.class); startActivity(TakePictureView); } }); TrainButton = (ImageButton) findViewById(R.id.Train); TrainButton.setActivated(false); TrainButton.setOnClickListener(change_button); CarButton = (ImageButton) findViewById(R.id.Car); CarButton.setActivated(true); CarButton.setOnClickListener(change_button); WalkButton = (ImageButton) findViewById(R.id.Walk); WalkButton.setActivated(false); WalkButton.setOnClickListener(change_button); buttons = Arrays.asList(TrainButton, CarButton, WalkButton); FrameSwitch = (ImageButton) findViewById(R.id.showFrame); FrameSwitch.setActivated(true); FrameSwitch.setOnClickListener(marker_change_button); PlaceSwitch = (ImageButton) findViewById(R.id.showPlace); PlaceSwitch.setActivated(true); PlaceSwitch.setOnClickListener(marker_change_button); GoFukuiButton = (ImageButton) findViewById(R.id.GoFukuiButton); // new AppSetting(this); // AppSetting.context = getApplicationContext(); AppSetting.Inc_CountRun(); e_print("Run_Count >> " + AppSetting.CountRun()); if (AppSetting.CountRun() % 20 == 0) { GoFukuiButton.setVisibility(View.VISIBLE); } FrameCollectionButton = (ImageButton) findViewById(R.id.frameCollection); FrameCollectionButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent collection = new Intent(getApplicationContext(), FrameCollection.class); startActivity(collection); } }); mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map); mapFragment.getMapAsync(this); // mapFragment.getMap(); helper = new SQLiteHelper(this); db = helper.getWritableDatabase(); }
From source file:hk.idv.kenson.jrconsole.Console.java
/** * /*from w ww . ja v a 2 s .co m*/ * @param localeString * @return */ private static Locale getLocale(String localeString) { if ("default".equals(localeString)) return Locale.getDefault(); if ("canada".equals(localeString)) return Locale.CANADA; if ("canada_french".equals(localeString)) return Locale.CANADA_FRENCH; if ("china".equals(localeString)) return Locale.CHINA; if ("chinese".equals(localeString)) return Locale.CHINESE; if ("english".equals(localeString)) return Locale.ENGLISH; if ("franch".equals(localeString)) return Locale.FRANCE; if ("german".equals(localeString)) return Locale.GERMAN; if ("germany".equals(localeString)) return Locale.GERMANY; if ("italian".equals(localeString)) return Locale.ITALIAN; if ("italy".equals(localeString)) return Locale.ITALY; if ("japan".equals(localeString)) return Locale.JAPAN; if ("japanese".equals(localeString)) return Locale.JAPANESE; if ("korea".equals(localeString)) return Locale.KOREA; if ("korean".equals(localeString)) return Locale.KOREAN; if ("prc".equals(localeString)) return Locale.PRC; if ("simplified_chinese".equals(localeString)) return Locale.SIMPLIFIED_CHINESE; if ("taiwan".equals(localeString)) return Locale.TAIWAN; if ("traditional_chinese".equals(localeString)) return Locale.TRADITIONAL_CHINESE; if ("uk".equals(localeString)) return Locale.UK; if ("us".equals(localeString)) return Locale.US; String parts[] = localeString.split("_", -1); if (parts.length == 1) return new Locale(parts[0]); else if (parts.length == 2) return new Locale(parts[0], parts[1]); else return new Locale(parts[0], parts[1], parts[2]); }
From source file:jp.terasoluna.fw.web.struts.form.FieldChecksExTest09.java
/** * testValidateDateRange02()//from w ww . j a va 2 s.c om * <br><br> * * (??n) * <br> * _?FC,F * <br><br> * l?F(?) bean:""<br> * (?) va:not null<br> * (?) field:not null<br> * Msg("message","message")<br> * (?) errors:not null<br> * (vf)<br> * (?) validator:not null<br> * (?) request:not null<br> * Locale=JAPANESE<br> * * <br> * l?F(l) boolean:true<br> * (?) errors:not null<br> * (vf)<br> * * <br> * ?bean?AtruepmF?B * <br> * * @throws Exception ?\bh?O */ public void testValidateDateRange02() throws Exception { //eXgf?[^? // ++++ beanIuWFNg ++++ String bean = ""; // ++++ ??IuWFNg ValidatorAction va = new ValidatorAction(); // ++++ ?tB?[h? Field field = new Field(); // ?bZ?[W? Msg msg = new Msg(); msg.setKey("message"); msg.setName("message"); msg.setResource(false); field.addMsg(msg); // G?[? ActionMessages errors = new ActionMessages(); // [HTTPNGXg MockHttpServletRequest request = new MockHttpServletRequest(); request.setLocale(Locale.JAPANESE); // ValidatorResourcesCX^X ValidatorResources validatorResources = new ValidatorResources(); // ValidatorCX^X Validator validator = new Validator(validatorResources); // eXg?s boolean result = FieldChecksEx.validateDateRange(bean, va, field, errors, validator, request); // eXgmF // truep?B assertTrue(result); // G?[??B assertTrue(errors.isEmpty()); }
From source file:jp.ne.sakura.kkkon.android.exceptionhandler.testapp.ExceptionHandlerReportApp.java
/** Called when the activity is first created. */ @Override// www. ja va2 s .c om public void onCreate(Bundle savedInstanceState) { final Context context = this.getApplicationContext(); { ExceptionHandler.initialize(context); if (ExceptionHandler.needReport()) { final String fileName = ExceptionHandler.getBugReportFileAbsolutePath(); final File file = new File(fileName); final File fileZip; { String strFileZip = file.getAbsolutePath(); { int index = strFileZip.lastIndexOf('.'); if (0 < index) { strFileZip = strFileZip.substring(0, index); strFileZip += ".zip"; } } Log.d(TAG, strFileZip); fileZip = new File(strFileZip); if (fileZip.exists()) { fileZip.delete(); } } if (file.exists()) { Log.d(TAG, file.getAbsolutePath()); InputStream inStream = null; ZipOutputStream outStream = null; try { inStream = new FileInputStream(file); String strFileName = file.getAbsolutePath(); { int index = strFileName.lastIndexOf(File.separatorChar); if (0 < index) { strFileName = strFileName.substring(index + 1); } } Log.d(TAG, strFileName); outStream = new ZipOutputStream(new FileOutputStream(fileZip)); byte[] buff = new byte[8124]; { ZipEntry entry = new ZipEntry(strFileName); outStream.putNextEntry(entry); int len = 0; while (0 < (len = inStream.read(buff))) { outStream.write(buff, 0, len); } outStream.closeEntry(); } outStream.finish(); outStream.flush(); } catch (IOException e) { Log.e(TAG, "got exception", e); } finally { if (null != outStream) { try { outStream.close(); } catch (Exception e) { } } outStream = null; if (null != inStream) { try { inStream.close(); } catch (Exception e) { } } inStream = null; } Log.i(TAG, "zip created"); } if (file.exists()) { // upload or send e-mail InputStream inStream = null; StringBuilder sb = new StringBuilder(); try { inStream = new FileInputStream(file); byte[] buff = new byte[8124]; int readed = 0; do { readed = inStream.read(buff); for (int i = 0; i < readed; i++) { sb.append((char) buff[i]); } } while (readed >= 0); final String str = sb.toString(); Log.i(TAG, str); } catch (IOException e) { Log.e(TAG, "got exception", e); } finally { if (null != inStream) { try { inStream.close(); } catch (Exception e) { } } inStream = null; } AlertDialog.Builder alertDialog = new AlertDialog.Builder(this); final Locale defaultLocale = Locale.getDefault(); String title = ""; String message = ""; String positive = ""; String negative = ""; boolean needDefaultLang = true; if (null != defaultLocale) { if (defaultLocale.equals(Locale.JAPANESE) || defaultLocale.equals(Locale.JAPAN)) { title = ""; message = "?????????"; positive = "?"; negative = ""; needDefaultLang = false; } } if (needDefaultLang) { title = "ERROR"; message = "Got unexpected error. Do you want to send information of error."; positive = "Send"; negative = "Cancel"; } alertDialog.setTitle(title); alertDialog.setMessage(message); alertDialog.setPositiveButton(positive + " mail", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface di, int i) { DefaultUploaderMailClient.upload(context, file, new String[] { "diverKon+sakura@gmail.com" }); } }); alertDialog.setNeutralButton(positive + " http", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface di, int i) { DefaultUploaderWeb.upload(ExceptionHandlerReportApp.this, fileZip, "http://kkkon.sakura.ne.jp/android/bug"); } }); alertDialog.setNegativeButton(negative, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface di, int i) { ExceptionHandler.clearReport(); } }); alertDialog.show(); } // TODO separate activity for crash report //DefaultCheckerAPK.checkAPK( this, null ); } ExceptionHandler.registHandler(); } super.onCreate(savedInstanceState); /* Create a TextView and set its content. * the text is retrieved by calling a native * function. */ LinearLayout layout = new LinearLayout(this); layout.setOrientation(LinearLayout.VERTICAL); TextView tv = new TextView(this); tv.setText("ExceptionHandler"); layout.addView(tv); Button btn1 = new Button(this); btn1.setText("invoke Exception"); btn1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { final int count = 2; int[] array = new int[count]; int value = array[count]; // invoke IndexOutOfBOundsException } }); layout.addView(btn1); Button btn2 = new Button(this); btn2.setText("reinstall apk"); btn2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { boolean foundApk = false; { final String apkPath = context.getPackageCodePath(); // API8 Log.d(TAG, "PackageCodePath: " + apkPath); final File fileApk = new File(apkPath); if (fileApk.exists()) { foundApk = true; Intent promptInstall = new Intent(Intent.ACTION_VIEW); promptInstall.setDataAndType(Uri.fromFile(fileApk), "application/vnd.android.package-archive"); promptInstall.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(promptInstall); } } if (false == foundApk) { for (int i = 0; i < 10; ++i) { File fileApk = new File("/data/app/" + context.getPackageName() + "-" + i + ".apk"); Log.d(TAG, "check apk:" + fileApk.getAbsolutePath()); if (fileApk.exists()) { Log.i(TAG, "apk found. path=" + fileApk.getAbsolutePath()); /* * // require parmission { final String strCmd = "pm install -r " + fileApk.getAbsolutePath(); try { Runtime.getRuntime().exec( strCmd ); } catch ( IOException e ) { Log.e( TAG, "got exception", e ); } } */ Intent promptInstall = new Intent(Intent.ACTION_VIEW); promptInstall.setDataAndType(Uri.fromFile(fileApk), "application/vnd.android.package-archive"); promptInstall.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(promptInstall); break; } } } } }); layout.addView(btn2); Button btn3 = new Button(this); btn3.setText("check apk"); btn3.setOnClickListener(new View.OnClickListener() { private boolean checkApk(final File fileApk, final ZipEntryFilter filter) { final boolean[] result = new boolean[1]; result[0] = true; final Thread thread = new Thread(new Runnable() { @Override public void run() { if (fileApk.exists()) { ZipFile zipFile = null; try { zipFile = new ZipFile(fileApk); List<ZipEntry> list = new ArrayList<ZipEntry>(zipFile.size()); for (Enumeration<? extends ZipEntry> e = zipFile.entries(); e.hasMoreElements();) { ZipEntry ent = e.nextElement(); Log.d(TAG, ent.getName()); Log.d(TAG, "" + ent.getSize()); final boolean accept = filter.accept(ent); if (accept) { list.add(ent); } } Log.d(TAG, Build.CPU_ABI); // API 4 Log.d(TAG, Build.CPU_ABI2); // API 8 final String[] abiArray = { Build.CPU_ABI // API 4 , Build.CPU_ABI2 // API 8 }; String abiMatched = null; { boolean foundMatched = false; for (final String abi : abiArray) { if (null == abi) { continue; } if (0 == abi.length()) { continue; } for (final ZipEntry entry : list) { Log.d(TAG, entry.getName()); final String prefixABI = "lib/" + abi + "/"; if (entry.getName().startsWith(prefixABI)) { abiMatched = abi; foundMatched = true; break; } } if (foundMatched) { break; } } } Log.d(TAG, "matchedAbi=" + abiMatched); if (null != abiMatched) { boolean needReInstall = false; for (final ZipEntry entry : list) { Log.d(TAG, entry.getName()); final String prefixABI = "lib/" + abiMatched + "/"; if (entry.getName().startsWith(prefixABI)) { final String jniName = entry.getName().substring(prefixABI.length()); Log.d(TAG, "jni=" + jniName); final String strFileDst = context.getApplicationInfo().nativeLibraryDir + "/" + jniName; Log.d(TAG, strFileDst); final File fileDst = new File(strFileDst); if (!fileDst.exists()) { Log.w(TAG, "needReInstall: content missing " + strFileDst); needReInstall = true; } else { assert (entry.getSize() <= Integer.MAX_VALUE); if (fileDst.length() != entry.getSize()) { Log.w(TAG, "needReInstall: size broken " + strFileDst); needReInstall = true; } else { //org.apache.commons.io.IOUtils.contentEquals( zipFile.getInputStream( entry ), new FileInputStream(fileDst) ); final int size = (int) entry.getSize(); byte[] buffSrc = new byte[size]; { InputStream inStream = null; try { inStream = zipFile.getInputStream(entry); int pos = 0; { while (pos < size) { final int ret = inStream.read(buffSrc, pos, size - pos); if (ret <= 0) { break; } pos += ret; } } } catch (IOException e) { Log.d(TAG, "got exception", e); } finally { if (null != inStream) { try { inStream.close(); } catch (Exception e) { } } } } byte[] buffDst = new byte[(int) fileDst.length()]; { InputStream inStream = null; try { inStream = new FileInputStream(fileDst); int pos = 0; { while (pos < size) { final int ret = inStream.read(buffDst, pos, size - pos); if (ret <= 0) { break; } pos += ret; } } } catch (IOException e) { Log.d(TAG, "got exception", e); } finally { if (null != inStream) { try { inStream.close(); } catch (Exception e) { } } } } if (Arrays.equals(buffSrc, buffDst)) { Log.d(TAG, " content equal " + strFileDst); // OK } else { Log.w(TAG, "needReInstall: content broken " + strFileDst); needReInstall = true; } } } } } // for ZipEntry if (needReInstall) { // need call INSTALL APK Log.w(TAG, "needReInstall apk"); result[0] = false; } else { Log.d(TAG, "no need ReInstall apk"); } } } catch (IOException e) { Log.d(TAG, "got exception", e); } finally { if (null != zipFile) { try { zipFile.close(); } catch (Exception e) { } } } } } }); thread.setName("check jni so"); thread.start(); /* while ( thread.isAlive() ) { Log.d( TAG, "check thread.id=" + android.os.Process.myTid() + ",state=" + thread.getState() ); if ( ! thread.isAlive() ) { break; } AlertDialog.Builder alertDialog = new AlertDialog.Builder( ExceptionHandlerTestApp.this ); final Locale defaultLocale = Locale.getDefault(); String title = ""; String message = ""; String positive = ""; String negative = ""; boolean needDefaultLang = true; if ( null != defaultLocale ) { if ( defaultLocale.equals( Locale.JAPANESE ) || defaultLocale.equals( Locale.JAPAN ) ) { title = ""; message = "???????"; positive = "?"; negative = ""; needDefaultLang = false; } } if ( needDefaultLang ) { title = "INFO"; message = "Now checking installation. Cancel check?"; positive = "Wait"; negative = "Cancel"; } alertDialog.setTitle( title ); alertDialog.setMessage( message ); alertDialog.setPositiveButton( positive, null); alertDialog.setNegativeButton( negative, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface di, int i) { if ( thread.isAlive() ) { Log.d( TAG, "request interrupt" ); thread.interrupt(); } else { // nothing } } } ); if ( ! thread.isAlive() ) { break; } alertDialog.show(); if ( ! Thread.State.RUNNABLE.equals(thread.getState()) ) { break; } } */ try { thread.join(); } catch (InterruptedException e) { Log.d(TAG, "got exception", e); } return result[0]; } @Override public void onClick(View view) { boolean foundApk = false; { final String apkPath = context.getPackageCodePath(); // API8 Log.d(TAG, "PackageCodePath: " + apkPath); final File fileApk = new File(apkPath); this.checkApk(fileApk, new ZipEntryFilter() { @Override public boolean accept(ZipEntry entry) { if (entry.isDirectory()) { return false; } final String filename = entry.getName(); if (filename.startsWith("lib/")) { return true; } return false; } }); } } }); layout.addView(btn3); Button btn4 = new Button(this); btn4.setText("print dir and path"); btn4.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { { final File file = context.getCacheDir(); Log.d(TAG, "Ctx.CacheDir=" + file.getAbsoluteFile()); } { final File file = context.getExternalCacheDir(); // API 8 if (null == file) { // no permission Log.d(TAG, "Ctx.ExternalCacheDir="); } else { Log.d(TAG, "Ctx.ExternalCacheDir=" + file.getAbsolutePath()); } } { final File file = context.getFilesDir(); Log.d(TAG, "Ctx.FilesDir=" + file.getAbsolutePath()); } { final String value = context.getPackageResourcePath(); Log.d(TAG, "Ctx.PackageResourcePath=" + value); } { final String[] files = context.fileList(); if (null == files) { Log.d(TAG, "Ctx.fileList=" + files); } else { for (final String filename : files) { Log.d(TAG, "Ctx.fileList=" + filename); } } } { final File file = Environment.getDataDirectory(); Log.d(TAG, "Env.DataDirectory=" + file.getAbsolutePath()); } { final File file = Environment.getDownloadCacheDirectory(); Log.d(TAG, "Env.DownloadCacheDirectory=" + file.getAbsolutePath()); } { final File file = Environment.getExternalStorageDirectory(); Log.d(TAG, "Env.ExternalStorageDirectory=" + file.getAbsolutePath()); } { final File file = Environment.getRootDirectory(); Log.d(TAG, "Env.RootDirectory=" + file.getAbsolutePath()); } { final ApplicationInfo appInfo = context.getApplicationInfo(); Log.d(TAG, "AppInfo.dataDir=" + appInfo.dataDir); Log.d(TAG, "AppInfo.nativeLibraryDir=" + appInfo.nativeLibraryDir); // API 9 Log.d(TAG, "AppInfo.publicSourceDir=" + appInfo.publicSourceDir); { final String[] sharedLibraryFiles = appInfo.sharedLibraryFiles; if (null == sharedLibraryFiles) { Log.d(TAG, "AppInfo.sharedLibraryFiles=" + sharedLibraryFiles); } else { for (final String fileName : sharedLibraryFiles) { Log.d(TAG, "AppInfo.sharedLibraryFiles=" + fileName); } } } Log.d(TAG, "AppInfo.sourceDir=" + appInfo.sourceDir); } { Log.d(TAG, "System.Properties start"); final Properties properties = System.getProperties(); if (null != properties) { for (final Object key : properties.keySet()) { String value = properties.getProperty((String) key); Log.d(TAG, " key=" + key + ",value=" + value); } } Log.d(TAG, "System.Properties end"); } { Log.d(TAG, "System.getenv start"); final Map<String, String> mapEnv = System.getenv(); if (null != mapEnv) { for (final Map.Entry<String, String> entry : mapEnv.entrySet()) { final String key = entry.getKey(); final String value = entry.getValue(); Log.d(TAG, " key=" + key + ",value=" + value); } } Log.d(TAG, "System.getenv end"); } } }); layout.addView(btn4); Button btn5 = new Button(this); btn5.setText("check INSTALL_NON_MARKET_APPS"); btn5.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { SettingsCompat.initialize(context); if (SettingsCompat.isAllowedNonMarketApps()) { Log.d(TAG, "isAllowdNonMarketApps=true"); } else { Log.d(TAG, "isAllowdNonMarketApps=false"); } } }); layout.addView(btn5); Button btn6 = new Button(this); btn6.setText("send email"); btn6.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent mailto = new Intent(); mailto.setAction(Intent.ACTION_SENDTO); mailto.setType("message/rfc822"); mailto.setData(Uri.parse("mailto:")); mailto.putExtra(Intent.EXTRA_EMAIL, new String[] { "" }); mailto.putExtra(Intent.EXTRA_SUBJECT, "[BugReport] " + context.getPackageName()); mailto.putExtra(Intent.EXTRA_TEXT, "body text"); //mailto.addFlags( Intent.FLAG_ACTIVITY_NEW_TASK ); //context.startActivity( mailto ); Intent intent = Intent.createChooser(mailto, "Send Email"); if (null != intent) { intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); try { context.startActivity(intent); } catch (android.content.ActivityNotFoundException e) { Log.d(TAG, "got Exception", e); } } } }); layout.addView(btn6); Button btn7 = new Button(this); btn7.setText("upload http thread"); btn7.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Log.d(TAG, "brd=" + Build.BRAND); Log.d(TAG, "prd=" + Build.PRODUCT); //$(BRAND)/$(PRODUCT)/$(DEVICE)/$(BOARD):$(VERSION.RELEASE)/$(ID)/$(VERSION.INCREMENTAL):$(TYPE)/$(TAGS) Log.d(TAG, "fng=" + Build.FINGERPRINT); final List<NameValuePair> list = new ArrayList<NameValuePair>(16); list.add(new BasicNameValuePair("fng", Build.FINGERPRINT)); final Thread thread = new Thread(new Runnable() { @Override public void run() { Log.d(TAG, "upload thread tid=" + android.os.Process.myTid()); try { HttpPost httpPost = new HttpPost("http://kkkon.sakura.ne.jp/android/bug"); //httpPost.getParams().setParameter( CoreConnectionPNames.SO_TIMEOUT, new Integer(5*1000) ); httpPost.setEntity(new UrlEncodedFormEntity(list, HTTP.UTF_8)); DefaultHttpClient httpClient = new DefaultHttpClient(); Log.d(TAG, "socket.timeout=" + httpClient.getParams().getIntParameter(CoreConnectionPNames.SO_TIMEOUT, -1)); Log.d(TAG, "connection.timeout=" + httpClient.getParams() .getIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, -1)); httpClient.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, new Integer(5 * 1000)); httpClient.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, new Integer(5 * 1000)); Log.d(TAG, "socket.timeout=" + httpClient.getParams().getIntParameter(CoreConnectionPNames.SO_TIMEOUT, -1)); Log.d(TAG, "connection.timeout=" + httpClient.getParams() .getIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, -1)); // <uses-permission android:name="android.permission.INTERNET"/> // got android.os.NetworkOnMainThreadException, run at UI Main Thread HttpResponse response = httpClient.execute(httpPost); Log.d(TAG, "response=" + response.getStatusLine().getStatusCode()); } catch (Exception e) { Log.d(TAG, "got Exception. msg=" + e.getMessage(), e); } Log.d(TAG, "upload finish"); } }); thread.setName("upload crash"); thread.start(); /* while ( thread.isAlive() ) { Log.d( TAG, "thread tid=" + android.os.Process.myTid() + ",state=" + thread.getState() ); if ( ! thread.isAlive() ) { break; } AlertDialog.Builder alertDialog = new AlertDialog.Builder( ExceptionHandlerTestApp.this ); final Locale defaultLocale = Locale.getDefault(); String title = ""; String message = ""; String positive = ""; String negative = ""; boolean needDefaultLang = true; if ( null != defaultLocale ) { if ( defaultLocale.equals( Locale.JAPANESE ) || defaultLocale.equals( Locale.JAPAN ) ) { title = ""; message = "???????"; positive = "?"; negative = ""; needDefaultLang = false; } } if ( needDefaultLang ) { title = "INFO"; message = "Now uploading error information. Cancel upload?"; positive = "Wait"; negative = "Cancel"; } alertDialog.setTitle( title ); alertDialog.setMessage( message ); alertDialog.setPositiveButton( positive, null); alertDialog.setNegativeButton( negative, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface di, int i) { if ( thread.isAlive() ) { Log.d( TAG, "request interrupt" ); thread.interrupt(); } else { // nothing } } } ); if ( ! thread.isAlive() ) { break; } alertDialog.show(); if ( ! Thread.State.RUNNABLE.equals(thread.getState()) ) { break; } } */ /* try { thread.join(); // must call. leak handle... } catch ( InterruptedException e ) { Log.d( TAG, "got Exception", e ); } */ } }); layout.addView(btn7); Button btn8 = new Button(this); btn8.setText("upload http AsyncTask"); btn8.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { AsyncTask<String, Void, Boolean> asyncTask = new AsyncTask<String, Void, Boolean>() { @Override protected Boolean doInBackground(String... paramss) { Boolean result = true; Log.d(TAG, "upload AsyncTask tid=" + android.os.Process.myTid()); try { //$(BRAND)/$(PRODUCT)/$(DEVICE)/$(BOARD):$(VERSION.RELEASE)/$(ID)/$(VERSION.INCREMENTAL):$(TYPE)/$(TAGS) Log.d(TAG, "fng=" + Build.FINGERPRINT); final List<NameValuePair> list = new ArrayList<NameValuePair>(16); list.add(new BasicNameValuePair("fng", Build.FINGERPRINT)); HttpPost httpPost = new HttpPost(paramss[0]); //httpPost.getParams().setParameter( CoreConnectionPNames.SO_TIMEOUT, new Integer(5*1000) ); httpPost.setEntity(new UrlEncodedFormEntity(list, HTTP.UTF_8)); DefaultHttpClient httpClient = new DefaultHttpClient(); Log.d(TAG, "socket.timeout=" + httpClient.getParams().getIntParameter(CoreConnectionPNames.SO_TIMEOUT, -1)); Log.d(TAG, "connection.timeout=" + httpClient.getParams() .getIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, -1)); httpClient.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, new Integer(5 * 1000)); httpClient.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, new Integer(5 * 1000)); Log.d(TAG, "socket.timeout=" + httpClient.getParams().getIntParameter(CoreConnectionPNames.SO_TIMEOUT, -1)); Log.d(TAG, "connection.timeout=" + httpClient.getParams() .getIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, -1)); // <uses-permission android:name="android.permission.INTERNET"/> // got android.os.NetworkOnMainThreadException, run at UI Main Thread HttpResponse response = httpClient.execute(httpPost); Log.d(TAG, "response=" + response.getStatusLine().getStatusCode()); } catch (Exception e) { Log.d(TAG, "got Exception. msg=" + e.getMessage(), e); result = false; } Log.d(TAG, "upload finish"); return result; } }; asyncTask.execute("http://kkkon.sakura.ne.jp/android/bug"); asyncTask.isCancelled(); } }); layout.addView(btn8); Button btn9 = new Button(this); btn9.setText("call checkAPK"); btn9.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { final boolean result = DefaultCheckerAPK.checkAPK(ExceptionHandlerReportApp.this, null); Log.i(TAG, "checkAPK result=" + result); } }); layout.addView(btn9); setContentView(layout); }