android-notifications

How to remove notification from notification bar programmatically in android?

霸气de小男生 提交于 2019-11-27 17:40:25
Anybody have idea how can we remove notification from application programmatically which is called using Pending intent. I have used to cancel notification using following method. AlarmManager am=(AlarmManager)getSystemService(Context.ALARM_SERVICE); Intent intent = new Intent(Display.this, TwoAlarmService.class); PendingIntent pi = PendingIntent.getBroadcast(Display.this, AlarmNumber, intent, PendingIntent.FLAG_CANCEL_CURRENT); am.cancel(pi); But problem is notification which fired already that are not removed from notification bar. Thanks in advance... Maybe try this : NotificationManager

Set notification to specific time

你。 提交于 2019-11-27 17:38:42
I would like my notification to run at 12:00pm everyday. How do you replace the when value with a time? NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); Notification notify = new Notification(R.drawable.icon,"Its Time to Eat",when); Context context = GrubNOWActivity.this; CharSequence title = "Its Time to Eat"; CharSequence details = "Click Here to Search for Restaurants"; Intent intent = new Intent(context,Search.class); PendingIntent pending = PendingIntent.getActivity(context, 0, intent, 0); notify.setLatestEventInfo(context, title, details,

How to Schedule Notification in Android

人盡茶涼 提交于 2019-11-27 17:08:20
I'm trying to set notification for a time in the future. I have the code for creating a notification but I can't find an option to schedule it. How can I schedule notifications? Shadab Ansari You need to use PendingIntent and BroadCastReceiver for this - public void scheduleNotification(Context context, long delay, int notificationId) {//delay is after how much time(in millis) from current time you want to schedule the notification NotificationCompat.Builder builder = new NotificationCompat.Builder(context) .setContentTitle(context.getString(R.string.title)) .setContentText(context.getString(R

Android Notification at time

你。 提交于 2019-11-27 16:34:10
问题 I am looking for hours now how to do this exactly: I want that every day (except weekends) a notification is sent at a time (let's say 18:00 (= 6pm)) except for when the app is open already. It's basically like the gmail app when you receive a mail. When the user clicks the notification it should disappear and should be brought to the MainActivity. I have tried numerous things with the AlarmManager, but none have resulted in a notification showing up. The code I tried, which I feel is pretty

Android SQLite DB notifications

与世无争的帅哥 提交于 2019-11-27 15:58:52
问题 I am writing an Android app that needs to be notified whenever a given SQLite database changes (any new row added, deleted or updated). Is there any programmatic way to listen to these notifications ? Is writing DB triggers for each table the only way ? 回答1: SQLite provides Data Change Notification Callbacks. I don't think that Android exposes them directly but it does have for example CursorAdapter which provides some change notifications. As thinksteep asked however, do you expect your DB

See notification of other app

这一生的挚爱 提交于 2019-11-27 15:24:42
问题 What API I should use for my app to see if I've received a notification from example from facebook, and so write in one textbox "Facebook!"? 回答1: Your best bet is to use NotificationListenerService, which was added in API level 18. Here's an example: public class FacebookNotificationListener extends NotificationListenerService { @Override public void onNotificationPosted(StatusBarNotification sbn) { final String packageName = sbn.getPackageName(); if (!TextUtils.isEmpty(packageName) &&

How to create Multiple statusbar Notifications in android

老子叫甜甜 提交于 2019-11-27 14:20:53
I need to create multiple statusbar notifications. When i pull down the statusbar, multiple notification icons should be displayed as a list. Each notification icon should show separate data to display on next page.How could i do this? My code: public class SimpleNotification extends Activity { private NotificationManager mNotificationManager; private int SIMPLE_NOTFICATION_ID; String str="Hai"; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mNotificationManager =

Bad notification posted - Couldn't expand RemoteViews for: StatusBarNotification

别来无恙 提交于 2019-11-27 14:16:12
I am trying to post a notification with a custom view in the notification area from an IntentService , and getting the Couldn't expand RemoteView error. Here's what I am doing in onCreate() : mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); icon = R.drawable.icon; tickerText = "data upload in progress"; contentView = new RemoteViews(getApplicationContext().getPackageName(), R.layout.notiflayout); contentView.setImageViewResource(R.id.image, R.drawable.icon); contentView.setTextViewText(R.id.text, "Hello"); contentView.setProgressBar(R.id.progressBar,

Why is this NotificationListenerService not working

谁说我不能喝 提交于 2019-11-27 13:04:31
问题 I'm fighting against the NotificationListenerService without much luck. I tried a lot of recipes found here and there, especially on so... But it works quite inconsistently. A first look at the code : Manifest : <service android:name=".services.NLService" android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE" > <intent-filter> <action android:name="android.service.notification.NotificationListenerService" /> </intent-filter> </service> Then the service itself : public

Notifications in specific time every day android

非 Y 不嫁゛ 提交于 2019-11-27 12:15:02
I'd like to make an app that let the user decide what time everyday wants him to remind something with notification... I'd like to know how am i supposed to trigger a notification in secific time the user wants e.x 7:00am and make him tap on the notification and enter the application in specific activity. But when the user doesn't want to get any more notifications (with a button click) how am i cancel all the notifications...? I made something like Intent intent = new Intent(this, main.class); Bundle bundle = new Bundle(); bundle.putString("title", "Some Title");\ intent.putExtras(bundle);