एंड्रॉइड के अंदर काम नहीं कर रहा है: मैं पैकेज स्थापित होने के बाद अधिसूचना बार से अधिसूचना रद्द करने का प्रयास कर रहा हूं।अधिसूचना प्रबंधक कैनसेल (आईडी) एक प्रसारण रिसीवर
public class MyBroadcastReceiver extends BroadcastReceiver {
private static final String TAG = "MyBroadcastReceiver";
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (Intent.ACTION_PACKAGE_ADDED.equals(action)) {
Uri data = intent.getData();
//some code goes here
//get the id of the notification to cancel in some way
notificationhelper._completeNotificationManager.cancel(id);
}
}
}
जहां
public class notificationhelper {
public static NotificationManager _completeNotificationManager = null;
public void complete() {
if (_completeNotificationManager == null)
_completeNotificationManager = (NotificationManager) _context.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(
R.drawable.notification,
_context.getString(R.string.notification),
System.currentTimeMillis());
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notification.flags |= Notification.FLAG_NO_CLEAR;
_completeNotificationManager.notify(TEXT, id, notification);
}
}
लेकिन notificationhelper._completeNotificationManager.cancel(id)
काम नहीं करता: क्या मैं कर रहा हूँ निम्नलिखित है। मैंने notificationhelper._completeNotificationManager.cancelAll();
का उपयोग करने की कोशिश की और यह काम करता है। क्या मैं गलत हूं?
मैं एक ही समस्या के आसपास अपने सिर खरोंच कर रहा था। stackoverflow.com/questions/38880330 मेरा दिन बचाया। – mauron85
क्या आप पूरा कोड अपलोड कर सकते हैं मेरे पास एक ही समस्या है? –
मैं 7 अंकों की यादृच्छिक संख्या उत्पन्न करता हूं, अभी भी अधिसूचना कॉन्सेल काम नहीं कर रहा है:/ –