gcm 메세지 수신시 소리를 변경하려고 하는데요, 인터넷 자료들은 정말 쉽게 설명이 되어 있는데요..
제가 실력이 없어서 하다하다 도움 좀 받기 위해 글을 올립니다.
public static void sendNotification(GCMIntentService gcmIntentService, Context context, String biz_name, String msg) {
NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
NotificationManager manger = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(com.kpreschool.test.R.drawable.ic_launcher, biz_name, System.currentTimeMillis());
PendingIntent contentIntent = PendingIntent.getActivity(context, NOTIFICATION_ID, new Intent(context, gcmIntentService.getClass()), 0);
notification.setLatestEventInfo(context, biz_name, msg, contentIntent);
notification.number = NOTIFICATION_ID;
notification.flags = Notification.FLAG_AUTO_CANCEL;
//notification.defaults |= Notification.DEFAULT_SOUND;
notification.sound = Uri.parse("android.resource://com.kpreschool.test/raw/mymusic");
notification.defaults |= Notification.DEFAULT_VIBRATE;
notification.defaults |= Notification.FLAG_SHOW_LIGHTS;
notification.defaults |= Notification.CONTENTS_FILE_DESCRIPTOR;
manger.notify(NOTIFICATION_ID++, notification);
}
코딩은 이렇게 여기저기 도움을 받아 작성해 놓았습니다.
res/raw 폴더 만들어 mymusic.mp3를 넣어 놓은 상태입니다.
gcm이 왔을때 mymusic.mp3가 실행되었으면 하는데요, 현재는 기본소리만 계속 나옵니다.
도움좀 부탁 드립니다.
답변 감사드립니다. 저의 자답입니다.
인터넷의 자료를 참고하면,
notification.sound = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.mymusic); 이렇게 또는