How to close the status bar/notification panel after notification button click
Use the following two code line to collapse the notification bar. Intent it = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS); context.sendBroadcast(it);
Use the following two code line to collapse the notification bar. Intent it = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS); context.sendBroadcast(it);
Create Notification using NotificationCompat.Builder NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_launcher) // notification icon .setContentTitle(“Notification!”) // title for notification .setContentText(“Hello word”) // message for notification .setAutoCancel(true); // clear notification after click Intent intent = new Intent(this, MainActivity.class); PendingIntent pi = PendingIntent.getActivity(this,0,intent,Intent.FLAG_ACTIVITY_NEW_TASK); mBuilder.setContentIntent(pi); NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); mNotificationManager.notify(0, mBuilder.build()); Push Notification on locked Screen http://www.hongkiat.com/blog/android-lock-screen-notifications/
As notification.userInfo type is AnyObject ayou must downcast it to appropriate dictionary type. After exact type of dictionary is known you don’t need to downcast values you get from it. But you may want to check if values are actually present in dictionary before using them: // First try to cast user info to expected … Read more
You may pass the parameter PendingIntent.getActivity(getApplicationContext(), 0, new Intent(), 0) instead of null on notification.setLatestEventInfo(context, contentTitle, contentText, null);
My extension in swift file extension Notification.Name { static let purchaseDidFinish = Notification.Name(“purchaseDidFinish”) } @objc extension NSNotification { public static let purchaseDidFinish = Notification.Name.purchaseDidFinish } // OBJECTIVE-C #import YourProjectName-Swift.h [NSNotificationCenter.defaultCenter addObserver:self selector:@selector(purchaseDidFinish) name:NSNotification.purchaseDidFinish object:nil]; // SWIFT NotificationCenter.default.addObserver(self, selector: #selector(purchaseDidFinish), name: .purchaseDidFinish, object: nil) @objc func purchaseDidFinish(notification: Notification) { print(“purchaseDidFinish”) } @leanne’s answer was super helpful
What you need is just a simple Activity that does nothing. Here is an example: public class NotificationActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Now finish, which will drop the user in to the activity that was at the top // of the task stack finish(); } } Set up … Read more
In Android Studio, go into Preferences > Appearance & Behavior > Notifications, go down to Gradle Build (Logging) and check the Read aloud box. This will speak Gradle build finished in x minutes and x seconds when your build is complete.
In my application I provide large (128×128 px) PNG drawable as small icon, and it shows scaled and without cropping. Is your drawable defined in bitmap file or maybe as XML resource? In XML you can specify several aspects of display (e.g. cropping). Double check your XML or use just PNG/JPG. As Android API documentation … Read more
You can’t make iOS show the alert again. Here’s a better approach: Keep a flag in your NSUserDefaults indicating whether you should register for push notifications at launch. By default the flag is false. When you launch, check the flag. If it’s true, register immediately. Otherwise, don’t register. The first time the user does something … Read more