我的错误在哪里?

时间:2015-11-20 18:37:44

标签: android permissions manifest

getAllCellInfo:用户10194和当前进程都没有android.permission.ACCESS_COARSE_LOCATION

<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
         package="com.r.raul.tools"> 

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> 
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" /> 

<application 
    android:allowBackup="true" 
    android:configChanges="orientation|screenSize" 
    android:icon="@mipmap/ic_launcher" 
    android:label="@string/app_name" 
    android:supportsRtl="true" 
    android:theme="@style/AppTheme"> 
    <activity 
        android:name=".MainActivity" 
        android:label="@string/app_name" 
        android:theme="@style/AppTheme.NoActionBar"> 
        <intent-filter> 
            <action android:name="android.intent.action.MAIN" /> 

            <category android:name="android.intent.category.LAUNCHER" /> 
        </intent-filter> 
    </activity> </application></manifest>  

3 个答案:

答案 0 :(得分:1)

如果您使用 broadcastreceiver ,请尝试更改我在下面添加的清单文件,

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.test"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="15" />

    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <receiver
            android:name="com.example.test.NetworkChangeReceiver"
            android:label="NetworkChangeReceiver" >
            <intent-filter>
                <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
            </intent-filter>
        </receiver>
    </application>

</manifest>

答案 1 :(得分:1)

可能是因为android权限。他们在android 6中有一些变化。检查this link以了解。转到Android设置 - &gt;应用并选择您的应用,然后手动接受权限并检查您的问题是否已解决。

答案 2 :(得分:0)

  TelephonyManager tm = (TelephonyManager) getActivity().getSystemService(Context.TELEPHONY_SERVICE);
          try {


            for (CellInfo info : tm.getAllCellInfo()) {
                if (info instanceof CellInfoGsm) {
                    CellSignalStrengthGsm gsm = ((CellInfoGsm) info).getCellSignalStrength();
                    // do what you need
                    gsmStrength = String.valueOf(gsm.getDbm());
                } else if (info instanceof CellInfoCdma) {
                    CellSignalStrengthCdma cdma = ((CellInfoCdma) info).getCellSignalStrength();
                    gsmStrength = String.valueOf(cdma.getDbm());
                } else if (info instanceof CellInfoLte) {
                    CellSignalStrengthLte lte = ((CellInfoLte) info).getCellSignalStrength();
                    gsmStrength = String.valueOf(lte.getDbm());
                } else {
                    gsmStrength = String.valueOf("Uknow");
                }
            }
          }catch (Exception e){
              LogUtils.LOG(e.getMessage());
          }