그림과 같이 상태 표시 줄에 전화기 아이콘을 추가하기 만하면됩니다. 더 이상은이 작은 아이콘이 상태 표시 줄에 표시되어야합니다.상태 표시 줄에 전화 아이콘 추가 (상태 표시 줄을 제거 할 위치)
어떻게하면됩니까? 일부 방법을 호출하여이 아이콘을 얻을 수 있습니까? 또는 어떤 도구로이 아이콘을 그려야합니까? 그런 다음이 아이콘을 추가하는 방법?
편집 : 마지막으로이 코드를 사용하여 알림을 보여 :
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_phone_white_36dp)
.setContentTitle("My notification")
.setContentText("Hello World!");
// Creates an explicit intent for an Activity in your app
Intent resultIntent = new Intent(this, SecondActivity.class);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
// Adds the back stack for the Intent (but not the Intent itself)
stackBuilder.addParentStack(SecondActivity.class);
// Adds the Intent that starts the Activity to the top of the stack
stackBuilder.addNextIntent(resultIntent);
PendingIntent resultPendingIntent =
stackBuilder.getPendingIntent(
0,
PendingIntent.FLAG_UPDATE_CURRENT
);
mBuilder.setContentIntent(resultPendingIntent);
mNotificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
// mId allows you to update the notification later on.
mNotificationManager.notify(2, mBuilder.build());
하지만 내 응용 프로그램에서이 작업을 사용하고 있습니다. 제거는 이제 문제입니다. 사용자가 프로그램을 종료 할 때이 알림을 제거하여 알림을 취소 할 위치를 지정하고 싶습니다.
mNotificationManager.cancel(2);
onDestroy에서 시도 : 작동하지 않으며 사용자가 프로그램을 종료 할 때 제거되지 않습니다.
@Override
protected void onDestroy() {
super.onDestroy(); // Always call the superclass method first
mNotificationManager.cancel(2);
}
onStop에서 시도 : 작동하지만 사용자가 다른 응용 프로그램을 통과하면이 알림이 제거됩니다. 나는 이것을 원하지 않는다.
@Override
protected void onStop() {
super.onStop(); // Always call the superclass method first
mNotificationManager.cancel(2);
}
마지막으로 취소 할 위치는 어디입니까?
https://developer.android.com/guide/topics/ui/notifiers/notifications.html을 확인하십시오. 아이콘은 알림 아이콘입니다. – rhari
프로그램을 종료하면 무엇을 의미합니까? – mallaudin
사용자가 두 번째 활동을 종료하면 사용자가 홈 버튼을 누르고 왼쪽으로 슬라이드하여 응용 프로그램을 종료합니다. –