service - Android Popup Screen like in WhatsApp or Telegram -


i'm new in android developing. searched lot , didn't find proper answer. want make pop-up/dialog screen displays when in service happens.

this screen should available when phone locked. found can make activity in dialog style or activity transparent background. don't think it's right way that. here 1 of screens (on right): link

you can scroll through messages , respond of them. debug phone has android 4.0.2 (so it's api level 14) , want use minimum requirement app.

edit: reply, tested notifications. problem is, smallicon shown in notification bar. no notification window or pop-up title or content... here implementation:

import com.google.android.gms.gcm.googlecloudmessaging; import android.app.intentservice; import android.app.notificationmanager; import android.app.pendingintent; import android.content.context; import android.content.intent; import android.support.v4.app.notificationcompat; import android.support.v4.app.taskstackbuilder; import android.util.log;  public class gcmintentservice extends intentservice {     public static final int notification_id = 1;       public gcmintentservice() {         super("gcmintentservice");     }      public static final string tag = "gcm test";      @override     protected void onhandleintent(intent intent) {         googlecloudmessaging gcm = googlecloudmessaging.getinstance(this);         string messagetype = gcm.getmessagetype(intent);         if (!intent.getextras().isempty()) {  // has effect of unparcelling bundle             if (googlecloudmessaging.message_type_send_error.equals(messagetype)) {                 sendnotification("send error: " + intent.getextras().tostring());             } else if (googlecloudmessaging.message_type_deleted.equals(messagetype)) {                 sendnotification("deleted messages on server: " + intent.getextras().tostring());                 // if it's regular gcm message, work.             } else if (googlecloudmessaging.message_type_message.equals(messagetype)) {                 // post notification of received message.                 sendnotification("message:\n" + intent.getstringextra("message"));                 log.i(tag, "received: " + intent.getextras().tostring());             }         }         // release wake lock provided wakefulbroadcastreceiver.         gcmbroadcastreceiver.completewakefulintent(intent);     }      private void sendnotification(string msg) {         notificationcompat.builder mbuilder =                 new notificationcompat.builder(this)                         .setsmallicon(r.drawable.ic_check)                         .setcontenttitle("my notification")                         .setcontenttext(msg);         intent resultintent = new intent(this, popupmessageactivity.class);         taskstackbuilder stackbuilder = taskstackbuilder.create(this);         stackbuilder.addparentstack(popupmessageactivity.class);         stackbuilder.addnextintent(resultintent);         pendingintent resultpendingintent =                 stackbuilder.getpendingintent(                         0,                         pendingintent.flag_update_current                 );         mbuilder.setcontentintent(resultpendingintent);         notificationmanager mnotificationmanager =                 (notificationmanager) getsystemservice(context.notification_service);         mnotificationmanager.notify(notification_id, mbuilder.build());     } } 

notifications you're looking for

here's link android developer page : http://developer.android.com/guide/topics/ui/notifiers/notifications.html

toasts might : http://developer.android.com/guide/topics/ui/notifiers/toasts.html

good luck !


Comments