Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/205.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 安卓4.2上的接近警报_Android_Proximity - Fatal编程技术网

Android 安卓4.2上的接近警报

Android 安卓4.2上的接近警报,android,proximity,Android,Proximity,在我的项目中,我使用的是接近警报,它在安卓4.1版本API 16上运行良好,但在安卓4.2 API 17上无法运行。我需要添加一些额外的标志或什么吗 loctionContex = Context.LOCATION_SERVICE; LocationManager locationManager = (LocationManager)getSystemService(loctionContex); Intent intent1 = new Intent(PROXIMITY_ALERT); P

在我的项目中,我使用的是接近警报,它在安卓4.1版本API 16上运行良好,但在安卓4.2 API 17上无法运行。我需要添加一些额外的标志或什么吗

loctionContex  = Context.LOCATION_SERVICE;
LocationManager locationManager = (LocationManager)getSystemService(loctionContex);

Intent intent1 = new Intent(PROXIMITY_ALERT);
PendingIntent proximityIntent = PendingIntent.getBroadcast(this, 0, intent1, 0);

locationManager.addProximityAlert(lat, lng, 4, -1, proximityIntent); 

IntentFilter filter = new IntentFilter(PROXIMITY_ALERT);

 registerReceiver(new ProximityIntentReceiver(), filter);
舱单:


请看下面的链接,你有访问权限吗?从文档中可以看出:在API版本17之前,此方法可用于ACCESS\u FINE\u位置或ACCESS\u Rough\u位置。从API版本17及以后,此方法需要访问\u FINE\u位置权限。@cermak.cz仍然不走运:我添加了我的清单
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>

<application

    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.example.proximityalert.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>