Tengo el siguiente codigo:
TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
// TODO: Consider calling
// ActivityCompat#requestPermissions
// here to request the missing permissions, and then overriding
// public void onRequestPermissionsResult(int requestCode, String[] permissions,
// int[] grantResults)
// to handle the case where the user grants the permission. See the documentation
// for ActivityCompat#requestPermissions for more details.
return;
}
GsmCellLocation cellLocation = (GsmCellLocation) telephonyManager.getCellLocation();
String networkOperator = telephonyManager.getNetworkOperator();
String mcc = networkOperator.substring(0, 3);
Log.d("Tag=>", mcc);
Los permisos en el manifest estan habilitados, el logcat muestra lo siguiente:
01-31 13:17:15.787 4996-4996/? I/libpersona: KNOX_SDCARD checking this for 10317 01-31 13:17:15.787 4996-4996/? I/libpersona: KNOX_SDCARD not a persona 01-31 13:17:15.791 4996-4996/? E/Zygote: accessInfo : 0 01-31 13:17:15.800 4996-4996/? W/SELinux: SELinux selinux_android_compute_policy_index : Policy Index[1], Con:u:r:zygote:s0 SPD:SEPF_SECMOBILE_7.0_0006 RAM:SEPF_SECMOBILE_7.0_0004, [-1 -1 0 1 0 1] 01-31 13:17:15.801 4996-4996/? I/SELinux: SELinux: seapp_context_lookup: seinfo=untrusted, level=s0:c512,c768, pkgname=com.example.israel.localizacion2 01-31 13:17:15.804 4996-4996/? I/art: Late-enabling -Xcheck:jni 01-31 13:17:15.867 4996-4996/? D/TimaKeyStoreProvider: TimaSignature is unavailable 01-31 13:17:15.867 4996-4996/? D/ActivityThread: Added TimaKeyStore provider 01-31 13:17:16.378 4996-4996/com.example.israel.localizacion2 W/System: ClassLoader referenced unknown path: /data/app/com.example.israel.localizacion2-1/lib/arm64 01-31 13:17:16.399 4996-4996/com.example.israel.localizacion2 D/ContextRelationMgrBrdg: loadKlass() : caller=com.samsung.android.bridge.multiscreen.common.ContextRelationManagerBridge.:28 android.app.LoadedApk.makeApplication:833 01-31 13:17:16.425 4996-4996/com.example.israel.localizacion2 I/FirebaseInitProvider: FirebaseApp initialization unsuccessful 01-31 13:17:16.429 4996-4996/com.example.israel.localizacion2 I/InstantRun: starting instant run server: is main process 01-31 13:17:16.555 4996-4996/com.example.israel.localizacion2 W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable 01-31 13:17:16.695 4996-4996/com.example.israel.localizacion2 D/TextView: setTypeface with style : 0 01-31 13:17:16.696 4996-4996/com.example.israel.localizacion2 D/TextView: setTypeface with style : 0 01-31 13:17:16.702 4996-4996/com.example.israel.localizacion2 D/TextView: setTypeface with style : 0 01-31 13:17:16.703 4996-4996/com.example.israel.localizacion2 D/TextView: setTypeface with style : 0 01-31 13:17:16.704 4996-4996/com.example.israel.localizacion2 D/TextView: setTypeface with style : 0 01-31 13:17:16.706 4996-4996/com.example.israel.localizacion2 D/TextView: setTypeface with style : 0 01-31 13:17:16.707 4996-4996/com.example.israel.localizacion2 D/TextView: setTypeface with style : 0 01-31 13:17:16.708 4996-4996/com.example.israel.localizacion2 D/TextView: setTypeface with style : 0 01-31 13:17:16.709 4996-4996/com.example.israel.localizacion2 D/TextView: setTypeface with style : 0 01-31 13:17:16.746 4996-4996/com.example.israel.localizacion2 D/InputTransport: Input channel constructed: fd=77 01-31 13:17:16.748 4996-4996/com.example.israel.localizacion2 D/ViewRootImpl@6c6d012[MainActivity]: setView = DecorView@5f843e3[MainActivity] touchMode=true 01-31 13:17:16.806 4996-5017/com.example.israel.localizacion2 I/OpenGLRenderer: Initialized EGL, version 1.4 01-31 13:17:16.806 4996-5017/com.example.israel.localizacion2 D/OpenGLRenderer: Swap behavior 1 01-31 13:17:16.818 4996-5017/com.example.israel.localizacion2 D/libGLESv1: STS_GLApi : DTS is not allowed for Package : com.example.israel.localizacion2 01-31 13:17:16.822 4996-5017/com.example.israel.localizacion2 D/mali_winsys: EGLint new_window_surface(egl_winsys_display*, void*, EGLSurface, EGLConfig, egl_winsys_surface**, egl_color_buffer_format*, EGLBoolean) returns 0x3000, [1080x1920]-format:1 01-31 13:17:16.856 4996-4996/com.example.israel.localizacion2 W/art: Before Android 4.1, method int android.support.v7.widget.ListViewCompat.lookForSelectablePosition(int, boolean) would have incorrectly overridden the package-private method in android.widget.ListView 01-31 13:17:16.869 4996-4996/com.example.israel.localizacion2 D/ViewRootImpl@6c6d012[MainActivity]: MSG_RESIZED_REPORT: ci=Rect(0, 72 - 0, 0) vi=Rect(0, 72 - 0, 0) or=1 01-31 13:17:16.869 4996-4996/com.example.israel.localizacion2 D/ViewRootImpl@6c6d012[MainActivity]: MSG_WINDOW_FOCUS_CHANGED 1 01-31 13:17:16.870 4996-4996/com.example.israel.localizacion2 I/InputMethodManager: [IMM] startInputInner - mService.startInputOrWindowGainedFocus 01-31 13:17:16.891 4996-5011/com.example.israel.localizacion2 D/InputTransport: Input channel constructed: fd=84 01-31 13:17:30.825 4996-4996/com.example.israel.localizacion2 D/ViewRootImpl@6c6d012[MainActivity]: ViewPostImeInputStage processPointer 0 01-31 13:17:30.827 4996-4996/com.example.israel.localizacion2 W/System: ClassLoader referenced unknown path: /system/framework/QPerformance.jar 01-31 13:17:30.832 4996-4996/com.example.israel.localizacion2 E/BoostFramework: BoostFramework() : Exception_1 = java.lang.ClassNotFoundException: Didn't find class "com.qualcomm.qti.Performance" on path: DexPathList[[],nativeLibraryDirectories=[/system/lib64, /vendor/lib64]] 01-31 13:17:30.907 4996-4996/com.example.israel.localizacion2 D/ViewRootImpl@6c6d012[MainActivity]: ViewPostImeInputStage processPointer 1 01-31 13:17:31.718 4996-4996/com.example.israel.localizacion2 D/ViewRootImpl@6c6d012[MainActivity]: ViewPostImeInputStage processPointer 0 01-31 13:17:32.281 4996-4996/com.example.israel.localizacion2 D/ViewRootImpl@6c6d012[MainActivity]: ViewPostImeInputStage processPointer 1 01-31 13:18:32.237 4996-4996/com.example.israel.localizacion2 I/InputMethodManager: [IMM] startInputInner - mService.startInputOrWindowGainedFocus 01-31 13:18:32.251 4996-4996/com.example.israel.localizacion2 D/InputTransport: Input channel constructed: fd=87 01-31 13:18:32.251 4996-4996/com.example.israel.localizacion2 D/InputTransport: Input channel destroyed: fd=84 01-31 13:18:33.870 4996-4996/com.example.israel.localizacion2 D/ViewRootImpl@6c6d012[MainActivity]: MSG_WINDOW_FOCUS_CHANGED 0 01-31 13:18:34.152 4996-4996/com.example.israel.localizacion2 D/InputTransport: Input channel destroyed: fd=87
Pero no se observa nada en el log.d
, este mismo código funciona en lollipop
, que podría ser?, gracias por su ayuda.