Search in sources :

Example 1 with TelephonyManager

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());
}
Also used : WifiManager(android.net.wifi.WifiManager) ConnectivityManager(android.net.ConnectivityManager) InputMethodManager(android.view.inputmethod.InputMethodManager) ActivityManager(android.app.ActivityManager) WindowManager(android.view.WindowManager) PowerManager(android.os.PowerManager) AudioManager(android.media.AudioManager) StateManager(proton.inject.state.StateManager) TelephonyManager(android.telephony.TelephonyManager) Context(android.content.Context) LocationManager(android.location.LocationManager) ApplicationProvider(proton.inject.provider.ApplicationProvider) NotificationManager(android.app.NotificationManager) HandlerProvider(proton.inject.provider.HandlerProvider) RetainStateListener(proton.inject.state.RetainStateListener) SensorManager(android.hardware.SensorManager) AlarmManager(android.app.AlarmManager) Vibrator(android.os.Vibrator) KeyguardManager(android.app.KeyguardManager) ObserverRegister(proton.inject.observer.ObserverRegister)

Example 2 with TelephonyManager

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);
        }*/
}
Also used : ContentValues(android.content.ContentValues) TelephonyManager(android.telephony.TelephonyManager) ContentResolver(android.content.ContentResolver)

Example 3 with TelephonyManager

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;
}
Also used : TelephonyManager(android.telephony.TelephonyManager)

Example 4 with TelephonyManager

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;
}
Also used : TelephonyManager(android.telephony.TelephonyManager)

Example 5 with TelephonyManager

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;
}
Also used : TelephonyManager(android.telephony.TelephonyManager)

Aggregations

TelephonyManager (android.telephony.TelephonyManager)679 SubscriptionInfo (android.telephony.SubscriptionInfo)64 ConnectivityManager (android.net.ConnectivityManager)59 SubscriptionManager (android.telephony.SubscriptionManager)53 Context (android.content.Context)42 Method (java.lang.reflect.Method)40 Intent (android.content.Intent)34 IOException (java.io.IOException)30 SuppressLint (android.annotation.SuppressLint)29 ArrayList (java.util.ArrayList)26 PhoneAccountHandle (android.telecom.PhoneAccountHandle)24 NetworkTemplate (android.net.NetworkTemplate)22 NetworkPolicyManager.uidRulesToString (android.net.NetworkPolicyManager.uidRulesToString)20 PhoneAccount (android.telecom.PhoneAccount)19 Test (org.junit.Test)18 Preference (android.support.v7.preference.Preference)17 TelecomManager (android.telecom.TelecomManager)17 View (android.view.View)17 DialogInterface (android.content.DialogInterface)16 Resources (android.content.res.Resources)16