Android 4.2上的接近警报

时间:2013-01-28 08:20:45

标签: android proximity

在我的项目中我正在使用接近警报,它与android 4.1版本(API 16)一起工作正常但在android 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);

清单:

<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>

0 个答案:

没有答案