내 음악 플레이어 용으로 notification
을 구축 중이므로 어떤 음악이 재생되는지 표시합니다. 하지만 터치 할 때 함수를 추가하고 싶습니다. 내 레이아웃 player.xml
을 엽니 다. MainActivity.class
을 통해 배포됩니다.알림을 건드릴 때 어떻게 활동을 열 수 있습니까?
developer.android.com의 알림을 조사하고 알림을 클릭하면 배포 및 활동 방법을 찾았습니다. 그러나 그것은 효과가 없습니다. 답변에 대한 모든 사람에게
Notification.Builder builder = new Notification.Builder(getApplicationContext());
builder.setContentTitle(songsList.get(songIndex).get("songTitle"));
builder.setContentText("NexPlay™");
builder.setTicker(songsList.get(songIndex).get("songTitle"));
builder.setSmallIcon(R.drawable.ic_launcher);
builder.setSmallIcon(R.drawable.play_default);
builder.setAutoCancel(true);
builder.setPriority(0);
builder.setOngoing(true);
Notification notification = builder.build();
NotificationManager notificationManger =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManger.notify(01, notification);
감사합니다 -
여기에 내 현재 코드입니다!
나는 내 알림에
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, new Intent(this, NotificationToPlayer.class), 0);
builder.setContentIntent(pendingIntent);
을 추가하고 그것은 큰 일!
코드에서 '알림 내용 의도'를 설정해야하는 곳은 무엇입니까? –
다음 예제를 따르십시오 http://developer.android.com/training/notify-user/build-notification.html –