• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Run action/method when pushing notification

I got an app that user a timer. When the time on timer hit t= 0 a notification pops on the screen.
With a tap on the notification the vibration stops. It works both in home and locked screen.

But when on the locked screen, the phone requires the pin-code when pushing the notification to launch the method that stops the vibration. How can I code so that the pin-code is not required when pushing the notification?

Java:
  public void showNotification() {
        Intent i = new Intent(this, MyBroadcastReceiver.class);
        PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, i, 0 );
        NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(getApplicationContext(), "1")
            .setContentTitle("Timer Vibration")
                .setContentText("The timer is vibrating")
                // .setPriority(NotificationCompat.PRIORITY_DEFAULT)
                .setDefaults(NotificationCompat.DEFAULT_ALL) // Added by me
                .setPriority(NotificationCompat.PRIORITY_MAX) // Added by me
                .setContentIntent(pendingIntent)
                .setSmallIcon(R.drawable.ic_arrow_upward_black_24dp)
                .setAutoCancel(true);



       // mBuilder.build();

        NotificationManagerCompat notificatManager = NotificationManagerCompat.from(this);
        notificatManager.notify(70, mBuilder.build());

    }
 
I realize that the timer built in Android don't use notifications to alert the user. Instead a new window pops up on the screen that let the user shut down the signal.
Maybe there's a better way to do this?
 
Back
Top Bottom