0

알림 표시 줄에서 Launching Application을 제어하고 싶습니다. 그래서 나는이 바에서 어떤 아이콘의 어떤 행동이라도 가로 채고 싶다. 아래의 코드는 알림 아이콘이 응용 프로그램을 시작하는 방법을 보여줍니다.알림 아이콘을 제어하는 ​​방법은 무엇입니까?

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

나는 모든 의도를 감지하고 알림 표시 줄에서 실행중인 응용 프로그램을 befor 암호가 필요 인증 서비스를 구현하고 싶습니다.

답변

0

그래, 질문을 잘 이해하면 ... Intent을 섹션으로 보내지 않는 이유는 무엇입니까? 이처럼

:

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

이 내가 예와 함께 설명하려고합니다 위해 내가 무엇을 찾고되지 않습니다. 내 puted 코드는 내 응용 프로그램에서 내 응용 프로그램을 시작하기위한 대화 상자를 인쇄 할 수 있도록 응용 프로그램의 fron 상태 표시 줄을 시작하기 위해 만든 알림입니다. 상태 표시 줄에있는 모든 아이콘 (예 : – user2641131

+0

)으로 몇 가지 작업을하고 싶습니다. 설정은 상태 표시 줄에서 액세스 할 수 있습니다. 이 응용 프로그램에 대한 액세스를 제한하고 싶습니다. – user2641131

+0

죄송합니다. 이전에 질문을받지 못했습니다. 그래서 당신은 SYSTEM APP가 상태 표시 줄에서 접근되는 것을 피하고 싶습니까? –

관련 문제