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;
}
}
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;
}
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;
}
Aggregations