比较两个pendingIntent

时间:2016-09-05 11:22:22

标签: android android-pendingintent

我必须在创建另一个之前比较2 PendingIntent以删除proximityAlert,因为它似乎不起作用。 我有我的功能:

SharedPreferences pref =  getSharedPreferences("proximityService", Context.MODE_PRIVATE);

            int unique_id = pref.getInt("PENDING_UNIQUEID",0);
            removeProximityAlert(unique_id);



int requestId = (int) System.currentTimeMillis();

        SharedPreferences.Editor editor = sharedPref.edit();
        editor.putInt("PENDING_UNIQUEID", requestId);
        editor.commit();
        PendingIntent proximityIntent = PendingIntent.getBroadcast(getApplicationContext(), requestId, intentNew, 0);

并删除功能

public void removeProximityAlert(int unique_id) {

        String context = Context.LOCATION_SERVICE;
        LocationManager locationManager = (LocationManager) getSystemService(context);

        Intent anIntent = new Intent(PROX_ALERT_INTENT);


        PendingIntent operation =
                PendingIntent.getBroadcast(getApplicationContext(), unique_id, anIntent, 0);


        if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
            Log.e("error", "permission");
            return;
        }
        locationManager.removeProximityAlert(operation);
        if (mHandleMessageReceiver != null){
            unregisterReceiver(mHandleMessageReceiver);
        }
    }

所以,近距离没有被删除,我的广播继续接受甚至最后的接近,我认为问题是不同的待定内容,但我不明白是否是问题,所以我会知道如果我可以比较2个未决意图。

0 个答案:

没有答案