Search in sources :

Example 46 with TelephonyManager

use of android.telephony.TelephonyManager in project MyDiary by erttyy8821.

the class CallDialogFragment method onClick.

@Override
public void onClick(View v) {
    switch(v.getId()) {
        case R.id.But_contacts_call_call:
            TelephonyManager tm = (TelephonyManager) getActivity().getSystemService(Context.TELEPHONY_SERVICE);
            if (tm.getPhoneType() == TelephonyManager.PHONE_TYPE_NONE) {
                //No module for calling phone
                Toast.makeText(getActivity(), getString(R.string.contacts_call_phone_no_call_function), Toast.LENGTH_LONG).show();
            } else {
                //Can call phone
                Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + contactsPhoneNumber));
                startActivity(intent);
            }
            dismiss();
            break;
        case R.id.But_contacts_call_cancel:
            dismiss();
            break;
    }
}
Also used : TelephonyManager(android.telephony.TelephonyManager) Intent(android.content.Intent)

Example 47 with TelephonyManager

use of android.telephony.TelephonyManager in project android-job by evernote.

the class Device method getNetworkType.

@NonNull
public static JobRequest.NetworkType getNetworkType(Context context) {
    ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
    if (networkInfo == null || !networkInfo.isConnectedOrConnecting()) {
        return JobRequest.NetworkType.ANY;
    }
    TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    if (telephonyManager != null && telephonyManager.isNetworkRoaming()) {
        return JobRequest.NetworkType.CONNECTED;
    }
    boolean metered = ConnectivityManagerCompat.isActiveNetworkMetered(connectivityManager);
    return metered ? JobRequest.NetworkType.NOT_ROAMING : JobRequest.NetworkType.UNMETERED;
}
Also used : NetworkInfo(android.net.NetworkInfo) TelephonyManager(android.telephony.TelephonyManager) ConnectivityManager(android.net.ConnectivityManager) NonNull(android.support.annotation.NonNull)

Example 48 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 49 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 50 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)

Aggregations

TelephonyManager (android.telephony.TelephonyManager)294 NetworkPolicyManager.uidRulesToString (android.net.NetworkPolicyManager.uidRulesToString)20 SubscriptionManager (android.telephony.SubscriptionManager)20 Test (org.junit.Test)15 ConnectivityManager (android.net.ConnectivityManager)14 Context (android.content.Context)11 Intent (android.content.Intent)11 NetworkIdentity (android.net.NetworkIdentity)11 Method (java.lang.reflect.Method)11 GsmCellLocation (android.telephony.gsm.GsmCellLocation)10 PackageManager (android.content.pm.PackageManager)9 SubscriptionInfo (android.telephony.SubscriptionInfo)9 IntentFilter (android.content.IntentFilter)8 IOException (java.io.IOException)8 PackageInfo (android.content.pm.PackageInfo)7 ServiceState (android.telephony.ServiceState)7 NetworkPolicy (android.net.NetworkPolicy)6 WifiManager (android.net.wifi.WifiManager)6 DevicePolicyManagerInternal (android.app.admin.DevicePolicyManagerInternal)5 SharedPreferences (android.content.SharedPreferences)5