0

通知バーからアプリケーションの起動を制御したいと思います。したがって、このバーの任意のアイコンで任意のアクションを傍受したいと思います。以下のコードは、通知アイコンがアプリケーションを起動する方法の例を示しています。

 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));
    }

すべての意図を検出し、通知バーからアプリケーションを実行する前にパスワードを必要とする認証サービスを実装したいと考えています。

4

1 に答える 1