java.lang.SecurityException: Richiede ACCESS_FINE_LOCATION o ACCESS_COARSE_LOCATION autorizzazione

Sto sviluppando un android dove voglio arrivare utente posizione utilizzando NETWORK_PROVIDER,io non sto usando il GPS per questo scopo.Io sono sempre il seguente eccezione

java.lang.SecurityException: Richiede ACCESS_FINE_LOCATION o ACCESS_COARSE_LOCATION autorizzazione

e sto usando il seguente codice.]

tx=(TextView) findViewById(R.id.textView1);
    lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    lm.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 1000,
    10f, this);
    tx.setText("Status="+lm.isProviderEnabled(LocationManager.NETWORK_PROVIDER));

e file manifest

<application android:icon="@drawable/icon" android:label="@string/app_name">
    <activity android:name=".MainActivity" android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />
</application>

OriginaleL’autore Altaf | 2011-06-24

2 Replies
  1. 8

    Le autorizzazioni vengono inseriti nel manifesto tag (non l’applicazione di tag) io.e

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="package.mypackage" android:versionCode="1" android:versionName="1.2">
    <uses-sdk android:minSdkVersion="7" />
    
    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".MainActivity" android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    
    </application>
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />
    </manifest>

    OriginaleL’autore Adil Soomro

  2. 2

    Si prega di provare

    <application android:icon="@drawable/icon" android:label="@string/app_name">
    <activity android:name=".MainActivity" android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    </application>
    
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />

    OriginaleL’autore Nikhil

Lascia un commento