В дополнение к посту про вождение.
Это моя бумажка с вождения, в ней отмечены все сделанные мной ошибки.
Congrats! Be Informed that, £1,500,000 British Pounds has been Awarded to your Email held in April, 2011;
Fill Form;
Name....
Address...
Country...
Tel...
We await your Response
Your email address have won 2.5 million pounds.Names:Address:Country:Age:Измельчали, измельчали
Language, которую мне не хотелось выбрасывать.setDefault(). Сам по себе он не помог, поскольку менеджер ресурсов андроида использует локаль из своих настроек. Но и эти настройки можно изменить.
<string-array name="languages">
<item>English</item>
<item>Українська</item>
<item>Русский</item>
</string-array>
<string-array name="language_values">
<item>en</item>
<item>uk</item>
<item>ru</item>
</string-array>
PreferenceActivity.PreferenceActivity реализует интерфейс OnSharedPreferenceChangeListener . В метод onSharedPreferenceChanged помещаем следующий код:
String lang = prefs.getString(key, Consts.DEFAULT_LOCALE);
Utils.setLocale(this, lang);
Const.DEFAULT_LOCALE - это просто строка "en".Utils.setLocale() и происходит волшебство, размером всего в 5 строчек кода.
public static void setLocale(Activity a, String lang) {
Locale locale2 = new Locale(lang);
Locale.setDefault(locale2);
Configuration c = new Configuration(a.getBaseContext().getResources().getConfiguration());
c.locale = locale2;
a.getBaseContext().getResources().updateConfiguration(c, a.getBaseContext().getResources().getDisplayMetrics());
}
locale2 - это наша новая локаль, создаваемая с переданным кодом языка. Код берется из массива language_values. Сперва мы устанавливаем ее как локаль по умолчанию для Java, а затем изменяем конфигурацию менеджера ресурсов андроида. Благодаря этому при загрузке ресурсов будут использоваться ресурсы, соответствующие новой локали. Все активити, созданные после этого будут использовать ресурсы в только-что установленной локали. Правда, все активити, которые уже созданы не поменяются.onCreate(), сразу после super(): Utils.setLocale(this);. Это перегруженный метод setLocale, который берет текущий язык приложения из SharePreferences. Выглядит он так:
public static void setLocale(Activity a) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(a);
setLocale(a, prefs.getString(Consts.PREF_LOCALE, Consts.DEFAULT_LOCALE));
}
Теперь мое приложение поддерживает локализацию на три языка - английский, украинский и русский, использует только стандартные средства системы андроид и позволяет пользователю менять язык приложения на лету через окно настроек. PROFIT!!!
static const int offset = 958;
static const int slope_coef = 10;
static const int slope = 307;
int get_humidity() {
long voltage = analogRead(0); // получить значение 0..1023
voltage = voltage * 5000 / 1023; // преобразовать в микровольты
// вычислим относительную влажность в процентах
return ((voltage - offset) * slope / slope_coef) / 100;
}
/*
Library of utility classes and functions for Arduino weather station
*/
#ifndef WEATHER_H
#define WEATHER_H
#include "WProgram.h"
// interface for humidity sensor HIH-4030
class Humidity {
private:
static const int offset = 958;
static const int slope_coef = 10;
static const int slope = 307;
int pin;
public:
Humidity(const int pin = 0);
// returns relative humidity in percents * 10
// to get actual humidity delete results by ten
long get_humidity();
int get_humidity_int();
};
#define I2C_ADDRESS 0x77
#define DEFAULT_OVERSAMPLING 3
class TemperaturePressure {
private:
int i2c_address;
unsigned char oversampling_setting; //oversamplig for measurement
static const unsigned char pressure_waittime[];// = { 5, 8, 14, 26 };
//taken straight from the BMP085 datasheet
int ac1, ac2, ac3;
unsigned int ac4, ac5, ac6;
int b1, b2, mb, mc, md;
int _temp;
long _pressure;
void get_calibration_data();
int read_int_register(unsigned char reg);
char read_register(unsigned char reg);
void write_register(unsigned char reg, unsigned char value);
unsigned int read_ut();
long read_up();
void read_temperature_and_pressure();
public:
TemperaturePressure();
TemperaturePressure(const int i2c_address, const int oversampling);
void read_data_from_sensor();
int get_temperature();
long get_pressure();
long get_pressure_hg();
void begin();
};
#endif
#include <wire.h>
#include <weather.h>
#define HUMIDITY_PIN 0
Humidity humidity(HUMIDITY_PIN);
TemperaturePressure tempPres;
void setup() {
Serial.begin(9600);
Serial.println("Calibrating...");
tempPres.begin();
Serial.println("Calibrated");
// Light the LED when ready
pinMode(13, OUTPUT);
digitalWrite(13, HIGH);
}
void loop() {
int h = humidity.get_humidity_int();
tempPres.read_data_from_sensor();
int t = tempPres.get_temperature();
float p = tempPres.get_pressure() * 7.5006e-3; // convert to mmHg
Serial.print(t/10.0);
Serial.print(";");
Serial.print(p);
Serial.print(";");
Serial.println(h);
delay(60000);
}
Imagine if 10% of the apps on iPhone came from Flash. If that was the case, then ensuring Flash didn’t break release to release would be a big deal, much bigger than any other compatibility issues. [...] Letting any of these secondary runtimes develop a significant base of applications in the store risks putting Apple in a position where the company that controls that runtime can cause delays in Apple’s release schedule, or worse, demand specific engineering decisions from Apple, under the threat of withholding the information necessary to keep their runtime working.