Java Code Examples for com.hyphenate.util.EasyUtils#isAppRunningForeground()
The following examples show how to use
com.hyphenate.util.EasyUtils#isAppRunningForeground() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EaseNotifier.java From Social with Apache License 2.0 | 6 votes |
/** * 处理新收到的消息,然后发送通知 * * 开发者可以重载此函数 * this function can be override * * @param message */ public synchronized void onNewMsg(EMMessage message) { if(EMClient.getInstance().chatManager().isSlientMessage(message)){ return; } EaseSettingsProvider settingsProvider = EaseUI.getInstance().getSettingsProvider(); if(!settingsProvider.isMsgNotifyAllowed(message)){ return; } // 判断app是否在后台 if (!EasyUtils.isAppRunningForeground(appContext)) { EMLog.d(TAG, "app is running in backgroud"); sendNotification(message, false); } else { sendNotification(message, true); } viberateAndPlayTone(message); }
Example 2
Source File: EaseNotifier.java From Social with Apache License 2.0 | 6 votes |
public synchronized void onNewMesg(List<EMMessage> messages) { if(EMClient.getInstance().chatManager().isSlientMessage(messages.get(messages.size()-1))){ return; } EaseSettingsProvider settingsProvider = EaseUI.getInstance().getSettingsProvider(); if(!settingsProvider.isMsgNotifyAllowed(null)){ return; } // 判断app是否在后台 if (!EasyUtils.isAppRunningForeground(appContext)) { EMLog.d(TAG, "app is running in backgroud"); sendNotification(messages, false); } else { sendNotification(messages, true); } viberateAndPlayTone(messages.get(messages.size()-1)); }
Example 3
Source File: EaseNotifier.java From Study_Android_Demo with Apache License 2.0 | 6 votes |
/** * handle the new message * this function can be override * * @param message */ public synchronized void onNewMsg(EMMessage message) { if(EMClient.getInstance().chatManager().isSilentMessage(message)){ return; } EaseSettingsProvider settingsProvider = EaseUI.getInstance().getSettingsProvider(); if(!settingsProvider.isMsgNotifyAllowed(message)){ return; } // check if app running background if (!EasyUtils.isAppRunningForeground(appContext)) { EMLog.d(TAG, "app is running in backgroud"); sendNotification(message, false); } else { sendNotification(message, true); } vibrateAndPlayTone(message); }
Example 4
Source File: EaseNotifier.java From Study_Android_Demo with Apache License 2.0 | 6 votes |
public synchronized void onNewMesg(List<EMMessage> messages) { if(EMClient.getInstance().chatManager().isSilentMessage(messages.get(messages.size()-1))){ return; } EaseSettingsProvider settingsProvider = EaseUI.getInstance().getSettingsProvider(); if(!settingsProvider.isMsgNotifyAllowed(null)){ return; } // check if app running background if (!EasyUtils.isAppRunningForeground(appContext)) { EMLog.d(TAG, "app is running in backgroud"); sendNotification(messages, false); } else { sendNotification(messages, true); } vibrateAndPlayTone(messages.get(messages.size()-1)); }
Example 5
Source File: EaseNotifier.java From nono-android with GNU General Public License v3.0 | 6 votes |
/** * 处理新收到的消息,然后发送通知 * * 开发者可以重载此函数 * this function can be override * * @param message */ public synchronized void onNewMsg(EMMessage message) { if(EMClient.getInstance().chatManager().isSlientMessage(message)){ return; } EaseUI.EaseSettingsProvider settingsProvider = EaseUI.getInstance().getSettingsProvider(); if(!settingsProvider.isMsgNotifyAllowed(message)){ return; } // 判断app是否在后台 if (!EasyUtils.isAppRunningForeground(appContext)) { EMLog.d(TAG, "app is running in backgroud"); sendNotification(message, false); } else { sendNotification(message, true); } viberateAndPlayTone(message); }
Example 6
Source File: EaseNotifier.java From nono-android with GNU General Public License v3.0 | 6 votes |
public synchronized void onNewMesg(List<EMMessage> messages) { if(EMClient.getInstance().chatManager().isSlientMessage(messages.get(messages.size()-1))){ return; } EaseUI.EaseSettingsProvider settingsProvider = EaseUI.getInstance().getSettingsProvider(); if(!settingsProvider.isMsgNotifyAllowed(null)){ return; } // 判断app是否在后台 if (!EasyUtils.isAppRunningForeground(appContext)) { EMLog.d(TAG, "app is running in backgroud"); sendNotification(messages, false); } else { sendNotification(messages, true); } viberateAndPlayTone(messages.get(messages.size() - 1)); }
Example 7
Source File: HxMessageListener.java From FamilyChat with Apache License 2.0 | 6 votes |
@Override public void onMessageReceived(List<EMMessage> list) { KLog.i("HxMessageListener onMessageReceived : " + list); //应用处于后台就发送通知栏提醒 if (!EasyUtils.isAppRunningForeground(FCApplication.getInstance())) { FCNotifyUtils.getInstance().sendMessageNotifivation(list); } else { //应用处于前台就发送铃声、震动通知 //震动通知不受限制 //铃声通知需要检查单条消息所属会话是否无需提醒,多条消息不受限制 FCNotifyUtils.getInstance().vibratorNotify(); if (list.size() == 1 && !conversationSet.contains(list.get(0).getFrom())) FCNotifyUtils.getInstance().ringtongNotify(); else if (list.size() > 1) FCNotifyUtils.getInstance().ringtongNotify(); } //通知刷新未读消息数 EventBusHelper.getInstance().post(new ComNotifyEventBean(ComNotifyConfig.REFRESH_UNREAD_MSG)); //通知收到新消息 EventBusHelper.getInstance().post(new HxMessageEventBean(HxMessageEventBean.NEW_MESSAGE_RECEIVED, list)); }
Example 8
Source File: EaseNotifier.java From nono-android with GNU General Public License v3.0 | 5 votes |
public void onNewCmd(EMMessage message) { EaseUI.EaseSettingsProvider settingsProvider = EaseUI.getInstance().getSettingsProvider(); if(!settingsProvider.isMsgNotifyAllowed(message)){ return; } // 判断app是否在后台 if (!EasyUtils.isAppRunningForeground(appContext)) { sendNotification(message, false); } else { sendNotification(message, true); } viberateAndPlayTone(message); }