use of android.telephony.TelephonyManager in project AndroidTraining by mixi-inc.
the class DefaultModule method configure.
@SuppressWarnings("unchecked")
protected void configure() {
bind(Application.class).toProvider(ApplicationProvider.class).in(ApplicationScoped.class);
bind(Context.class).toProvider(ContextProvider.class);
bind(Handler.class).toProvider(HandlerProvider.class).in(ApplicationScoped.class);
bind(ActivityManager.class).toProvider(new SystemServiceProvider<ActivityManager>(Context.ACTIVITY_SERVICE));
bind(AlarmManager.class).toProvider(new SystemServiceProvider<AlarmManager>(Context.ALARM_SERVICE));
bind(AudioManager.class).toProvider(new SystemServiceProvider<AudioManager>(Context.AUDIO_SERVICE));
bind(ConnectivityManager.class).toProvider(new SystemServiceProvider<ConnectivityManager>(Context.CONNECTIVITY_SERVICE));
bind(InputMethodManager.class).toProvider(new SystemServiceProvider<InputMethodManager>(Context.INPUT_METHOD_SERVICE));
bind(KeyguardManager.class).toProvider(new SystemServiceProvider<KeyguardManager>(Context.KEYGUARD_SERVICE));
bind(LocationManager.class).toProvider(new SystemServiceProvider<LocationManager>(Context.LOCATION_SERVICE));
bind(NotificationManager.class).toProvider(new SystemServiceProvider<NotificationManager>(Context.NOTIFICATION_SERVICE));
bind(PowerManager.class).toProvider(new SystemServiceProvider<PowerManager>(Context.POWER_SERVICE));
bind(SensorManager.class).toProvider(new SystemServiceProvider<SensorManager>(Context.SENSOR_SERVICE));
bind(TelephonyManager.class).toProvider(new SystemServiceProvider<TelephonyManager>(Context.TELEPHONY_SERVICE));
bind(Vibrator.class).toProvider(new SystemServiceProvider<Vibrator>(Context.VIBRATOR_SERVICE));
bind(WifiManager.class).toProvider(new SystemServiceProvider<WifiManager>(Context.WIFI_SERVICE));
bind(WindowManager.class).toProvider(new SystemServiceProvider<WindowManager>(Context.WINDOW_SERVICE));
bind(mAccountManagerClass).toProvider(AccountManagerProvider.class);
bind(ObserverManager.class);
bindProviderListener(new ObserverRegister());
bind(StateManager.class).in(ApplicationScoped.class);
bind(StateEventObserver.class);
bindFieldListener(RetainState.class, new RetainStateListener());
}
use of android.telephony.TelephonyManager in project qksms by moezbhatti.
the class CursorUtils method prepareEmulator.
public static void prepareEmulator(Context context) {
TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
if (Integer.parseInt(telephonyManager.getDeviceId()) > 0)
return;
try {
context.getContentResolver().delete(Uri.parse("content://sms/"), null, null);
} catch (Exception e) {
e.printStackTrace();
}
ContentResolver contentResolver = context.getContentResolver();
String[][] messages = new String[][] { // address, body, date, type
{ "4165254009", "Why are you texting myself?", "1399856640", "" + Message.RECEIVED }, { "4166485592", "These popups are so handy!", "1400079840", "" + Message.RECEIVED } };
for (int i = 0; i < messages.length; i++) {
ContentValues cv = new ContentValues();
cv.put("address", messages[i][0]);
cv.put("body", messages[i][1]);
cv.put("date", messages[i][2]);
cv.put("date_sent", messages[i][2]);
cv.put("type", messages[i][3]);
contentResolver.insert(SmsHelper.SMS_CONTENT_PROVIDER, cv);
}
/*for (int i = 0; i < messages.length; i++) {
ContentValues cv = new ContentValues();
cv.put("date", messages[i][2]);
contentResolver.update(SmsHelper.CONVERSATIONS_CONTENT_PROVIDER, cv, "snippit=" + messages[i][1], null);
}*/
}
use of android.telephony.TelephonyManager in project qksms by moezbhatti.
the class NumberToContactFormatter method getCurrentCountryIso.
public String getCurrentCountryIso() {
if (mCountryIso == null) {
TelephonyManager tm = (TelephonyManager) QKSMSAppBase.getApplication().getSystemService(Context.TELEPHONY_SERVICE);
mCountryIso = tm.getNetworkCountryIso();
// Just in case the TelephonyManager method failed, fallback to US
if (mCountryIso == null) {
mCountryIso = "US";
}
mCountryIso = mCountryIso.toUpperCase();
}
return mCountryIso;
}
use of android.telephony.TelephonyManager in project qksms by moezbhatti.
the class ApnUtils method getSimOperatorCodes.
public static String[] getSimOperatorCodes(Context context) {
TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
String simOperator = telephonyManager.getSimOperator();
String[] mccmnc = new String[] { null, null };
if (!TextUtils.isEmpty(simOperator)) {
mccmnc[0] = simOperator.substring(0, 3);
mccmnc[1] = simOperator.substring(3);
}
return mccmnc;
}
use of android.telephony.TelephonyManager in project actor-platform by actorapp.
the class Devices method getDeviceCountry.
public static String getDeviceCountry() {
TelephonyManager tm = (TelephonyManager) AndroidContext.getContext().getSystemService(Context.TELEPHONY_SERVICE);
String country = tm.getSimCountryIso();
if (android.text.TextUtils.isEmpty(country)) {
country = tm.getNetworkCountryIso();
}
if (android.text.TextUtils.isEmpty(country)) {
country = AndroidContext.getContext().getResources().getConfiguration().locale.getCountry();
}
return country;
}
Aggregations