Android firebase广播导致应用程序崩溃

时间:2017-07-17 20:08:29

标签: android firebase firebase-cloud-messaging

我有这段代码,

     try {
        if (!NotificationUtils.isAppIsInBackground(getApplicationContext())) {
            // app is in foreground, broadcast the push message
            Intent pushNotification = new Intent(Config.PUSH_NOTIFICATION);
            pushNotification.putExtra("message", message);

            LocalBroadcastManager.getInstance(this).sendBroadcast(pushNotification);

            // play notification sound
            NotificationUtils notificationUtils = new NotificationUtils(getApplicationContext());
            notificationUtils.playNotificationSound();
        } else {
            // If the app is in background, firebase itself handles the notification
        }
    }
    catch (Exception ex)
    {
        Toast.makeText(getApplicationContext(),ex.getMessage(), Toast.LENGTH_LONG).show();
    }

它运行得很好,但是当它收到此行的通知时,应用程序突然崩溃了:

LocalBroadcastManager.getInstance(this).sendBroadcast(pushNotification);

永远不会输入catch异常! 我可以在logcat中看到:

com.package.myapp E/MediaPlayer: error (1, -2147483648)

0 个答案:

没有答案