Note that there are some explanatory texts on larger screens.

plurals
  1. PONot Getting notification in status bar while app running in background
    primarykey
    data
    text
    <p>When I receive messages while Google Chat is in the background, I am not getting any notification in the status bar.</p> <pre><code>public void showNotification(Context context, String msg, String title, String fromChatID) { int id = GTalkChatDetails.friendID.indexOf(fromChatID); NotificationManager = (NotificationManager) context.getSystemService(NOTIFICATION_SERVICE); int icon = R.drawable.statusicon; CharSequence tickerText = msg; long when = System.currentTimeMillis(); Notification notification = new Notification(icon, tickerText, when); notification.flags |= Notification.FLAG_AUTO_CANCEL; notification.flags |= Notification.DEFAULT_SOUND; CharSequence contentTitle = title; CharSequence contentText = msg; Intent notificationIntent = new Intent(context, GTChat.class); Bundle bun = new Bundle(); bun.putString("name", GTalkChatDetails.name); bun.putString("chatID", GTalkChatDetails.chatID); bun.putString("profileImage", GTalkChatDetails.profileImageURL); bun.putString("fromName", title); bun.putString("fromChatID", fromChatID); notificationIntent.putExtras(bun); PendingIntent contentIntent = PendingIntent.getActivity(context, id, notificationIntent,PendingIntent.FLAG_ONE_SHOT); notification.setLatestEventInfo(context, contentTitle, contentText,contentIntent); mNotificationManager.notify(id, notification); getCurrentActivity(context, msg, title, fromChatID); } public void getCurrentActivity(Context context, String msg, String fromName, String fromChatID) { ActivityManager am = (ActivityManager) context .getSystemService(ACTIVITY_SERVICE); List&lt;RunningTaskInfo&gt; taskInfo = am.getRunningTasks(1); ComponentName componentInfo = taskInfo.get(0).topActivity; if (componentInfo.getClassName().startsWith("com.project")) { showNotification(context, msg, fromName, fromChatID); } else { showNotification(context, msg, fromName, fromChatID); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload