Notification 5

89일차(1)/Android App(55) : mp3 파일 재생 예제 / Notification(3)

89일차(1)/Android App(55) : mp3 파일 재생 예제 / Notification(3) - Service 를 상속하고 서비스 onbind() 메소드를 오버라이드했다. - onCreate는 생성자처럼 최초 1번만 활성화되는 것! - onStartCommand는 이것을 활성화시킬 intent가 도착하면 여러번 호출되는 것. - 이전예제에서는 액티비티에서 MediaPlayer 를 사용해서 재생하게 되어있는데, Service 안에서 재생하는 것으로 바꾸어 볼 예정! (액티비티의 활성화/비활성화와 상관없이 백그라운드에서 계속 재생될 수 있도록 하기 위해서!) - Onstart에서 서비스를 시작시키고 → 서비스 바인딩 설정 → 알림바의 기능버튼을 사용할 수 있도록 수정할 것 - 액티비티의 내용을 se..

국비교육(22-23) 2023.02.16

88일차(2)/Android App(54) : mp3 파일 재생 예제 / Notification(2)

88일차(2)/Android App(54) : mp3 파일 재생 예제 / Notification(2) - 새 서비스 생성 MusicService 생성 package com.example.step23mp3player; import android.app.Service; import android.content.Intent; import android.os.IBinder; import android.util.Log; public class MusicService extends Service { //서비스가 최초 활성화될 때 한번 호출되는 메소드 @Override public void onCreate() { super.onCreate(); } //최초 활성화 혹은 이미 활성화된 이후 이 서비스를 활성화 하는 I..

국비교육(22-23) 2023.02.15

88일차(1)/Android App(53) : mp3 파일 재생 예제 / Notification(1)

88일차(1)/Android App(53) : mp3 파일 재생 예제 / Notification(1) MainActivity package com.example.step23mp3player; import android.app.Notification; import android.app.NotificationChannel; import android.app.NotificationManager; import android.content.Context; import android.content.pm.PackageManager; import android.media.AudioManager; import android.media.MediaPlayer; import android.os.Build; import and..

국비교육(22-23) 2023.02.14

85일차(1)/Android App(49) : Notification(2)

85일차(1)/Android App(49) : Notification(2) - 알림Notification 띄우기 / 자동,수동 삭제 방법 - 이전 예제에서 만든 자동으로 사라지는 알림 창 코드 복습! - 알림 창을 클릭하면 어떤 액티비티가 활성화되면서 알림이 사라진다. (DetailActivity 로 이동하도록 함) [ 알림을 띄우기 위해서 필요한 작업 ] 1. 알림 채널을 만들어야 한다. 2. 사용자가 직접 알림을 허용하도록 유도해야 한다. 3. AndroidManifest.xml에 알림 pemission 설정이 있어야 한다. - 알림 띄우기 버튼을 클릭하면, 알림 권한이 켜져있는지 꺼져있는지 확인해서 꺼져있으면 켜도록 요청했다. - 채널은 최초에 한번만 만들면 된다. - 이전에 만든 코드로는 알림을 ..

국비교육(22-23) 2023.02.09