Ich habe die Erlaubnis von android.permission.ACCESS_COARSE_LOCATION
in der Manifest.xml und Code ist unten."Weder Benutzer 10046 noch aktueller Prozess hat android.permission.ACCESS_COARSE_LOCATION" aber es ist in meinem Manifest
TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
GsmCellLocation location = (GsmCellLocation) tm.getCellLocation();
int cellID = location.getCid();
int lac = location.getLac();
Toast.makeText(getApplicationContext(), cellID, Toast.LENGTH_LONG).show();
Allerdings stürzte es mit der folgenden Fehlermeldung ab. Bitte prüfen Sie, wie Sie diese Art von Problem lösen können.
05-15 23:23:09.844 22602-22602/use.uevision.com.myapplication E/AndroidRuntime: FATAL EXCEPTION: main
Process: use.uevision.com.myapplication, PID: 22602
java.lang.RuntimeException: Unable to start activity ComponentInfo{cctvkim.truevision.com.myapplication/cctvkim.truevision.com.myapplication.MainActivity}: java.lang.SecurityException: getCellLocation: Neither user 10046 nor current process has android.permission.ACCESS_COARSE_LOCATION.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3253)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3349)
at android.app.ActivityThread.access$1100(ActivityThread.java:221)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7225)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: java.lang.SecurityException: getCellLocation: Neither user 10046 nor current process has android.permission.ACCESS_COARSE_LOCATION.strong text
at android.os.Parcel.readException(Parcel.java:1620)
at android.os.Parcel.readException(Parcel.java:1573)
at com.android.internal.telephony.ITelephony$Stub$Proxy.getCellLocation(ITelephony.java:3311)
at android.telephony.TelephonyManager.getCellLocation(TelephonyManager.java:963)
at cctvkim.truevision.com.myapplication.MainActivity.onCreate(MainActivity.java:21)
at android.app.Activity.performCreate(Activity.java:6876)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3206)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3349)
at android.app.ActivityThread.access$1100(ActivityThread.java:221)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7225)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
05-15 23:23:13.804 22602-22602/cctvkim.truevision.com.myapplication I/Process: Sending signal. PID: 22602 SIG: 9
E/Android Runtime: fatal EXCEPTION: main Prozess: cctvkim.truevision.com.myapplication, PID: 10696 java.lang.RuntimeException: Kann nicht Aktivität ComponentInfo {cctvkim.truevision.com.myapplication/cctvkim.truevision starten. com.myapplication.MainActivity}: android.content.res.Resources $ NotFoundException: String resource ID # 0x261e60e –
Vielen Dank für Ihre freundliche Antwort. Ich habe getan, wie Sie gesagt haben, aber ich habe die andere Fehlermeldung wie oben. Wenn ich nur "Hallo" anstoße, funktioniert es, aber wenn ich versuche, cellID oder lac zu toasten, ist es abgestürzt. Irgendeine Idee?? –
eine andere Fehlermeldung bedeutet ein anderes Problem. Wenn ich dein Problem gelöst habe - akzeptiere meine Antwort. Die andere Fehlermeldung, die Sie erhalten haben, sieht so aus, als ob Ihr Standort immer noch Null ist und Sie versuchen, Daten von ihm zu erhalten. Umgeben Sie es mit if (location! = Null) –