0

I would like to control Launching Application from notification bar. So i would like to intercept any action in any icon in this bar. the code given below give an example of how a notification icon start the application that much with it.

 private void handleCommand(Intent intent){
        // In this sample, we'll use the same text for the ticker and the expanded notification
        CharSequence text = getText(R.string.service_running);

        // Set the icon, scrolling text and timestamp
        Notification notification = new Notification(R.drawable.statusbar_icon, text,
                System.currentTimeMillis());

        // The PendingIntent to launch our activity if the user selects this notification
        PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
                new Intent(this, AppLockerActivity.class), 0);

        // Set the info for the views that show in the notification panel.
        notification.setLatestEventInfo(this, text,
                       text, contentIntent);

        startForegroundCompat(R.string.service_running, notification);

        startMonitorThread((ActivityManager)this.getSystemService(Context.ACTIVITY_SERVICE));
    }

I would like to detect all the intent and implement a service of authentication that need a password befor running applications from the notification bar.

user2641131
  • 1
  • 1
  • 4

1 Answers1

0

Ok so, if i understood well the question...why don't make Intent to send to some kind of Login section?

Like this:

 private void handleCommand(Intent intent){
    // In this sample, we'll use the same text for the ticker and the expanded notification
    CharSequence text = getText(R.string.service_running);

    // Set the icon, scrolling text and timestamp
    Notification notification = new Notification(R.drawable.statusbar_icon, text,
            System.currentTimeMillis());


    //create an intent and add some Extra or whatever else you need
    Intent intent = new Intent(this, YOUR_LOGIN_CLASS.class);
    intent.addExtra("WHATEVER TO RETRIEVE TO SEE IF COME FROM NOTIFICATION",whatever);

    // The PendingIntent to launch our activity if the user selects this notification
    PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
            intent, 0);

    // Set the info for the views that show in the notification panel.
    notification.setLatestEventInfo(this, text,
                   text, contentIntent);

    startForegroundCompat(R.string.service_running, notification);

    startMonitorThread((ActivityManager)this.getSystemService(Context.ACTIVITY_SERVICE));
}
Stefano Munarini
  • 2,711
  • 2
  • 22
  • 26
  • this is not what i am looking for I will try to explain with an example. The code that i puted is a notification created in my application to launch my application fron status bar, so i can print a dialog box befor launching my application. I would like to do the some thing with all icon in status bar – user2641131 Sep 05 '13 at 10:19
  • for example Setting is accessible from status bar. i would like to limit acces to this application. – user2641131 Sep 05 '13 at 10:20
  • Ok, sorry i didn't get your question before. So you want to avoid SYSTEM APP to be accessed from status bar? – Stefano Munarini Sep 05 '13 at 12:36
  • I would like that any application launched from the status bar will be control with a passeword. – user2641131 Sep 05 '13 at 12:59