FirebaseでPush通知を処理するプログラムを作っています。
端末がスリープ状態にある時、通知を受けた時点でスリープから復帰したいのですが、
どうしても出来ません。
import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.media.AudioManager; import android.media.RingtoneManager; import android.net.Uri; import com.google.firebase.messaging.FirebaseMessagingService; import com.google.firebase.messaging.RemoteMessage; import java.util.Map; import biz.flashsystem.cmasystem.HomeActivity; import biz.flashsystem.cmasystem.R; import static android.app.Notification.DEFAULT_ALL; import static android.app.Notification.PRIORITY_MAX; /** * Created by WestField_w7 on 2016/09/13. */ public class FcmMessagingService extends FirebaseMessagingService { private String TAG = "FcmMessagingService"; @Override public void onMessageReceived(RemoteMessage remoteMessage) { if (remoteMessage.getData().size() > 0) { Map<String, String> data = remoteMessage.getData(); String title = data.get("custom_title"); String body = data.get("custom_body"); sendNotification(title, body); } if (remoteMessage.getNotification() != null) { } } private void sendNotification(String messageTitle, String messageBody) { Intent intent = new Intent(this, HomeActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent, PendingIntent.FLAG_ONE_SHOT); Uri defaultSoundUri= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); Notification notification = new Notification.Builder(this) .setSmallIcon(R.mipmap.ic_launcher) .setContentTitle(messageTitle) .setContentText(messageBody) .setAutoCancel(true) .setDefaults(DEFAULT_ALL) .setPriority(PRIORITY_MAX) .setContentIntent(pendingIntent) .build(); NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(1, notification); } }
現在は上記のように作っているのですが、上記だとスリープから復帰するどころか音も鳴らずバイブもしません。
どうすれば良いのでしょうか?
宜しくお願い致します。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。