Monday 15 June 2015

How do I create an Android notification? -



How do I create an Android notification? -

i followed tutorial step step maintain getting unusual errors.

the notifymanager doesn't have .notify() method , line of code notifymanager in must have brackets regardless of within code.

i'm origin think it's dependency issue, please help!

activity 1

import android.os.bundle; import android.app.activity; import android.app.notification; import android.app.notificationmanager; import android.app.pendingintent; import android.content.context; import android.content.intent; public class notificationalert extends activity { private static final int notify_me_id=1337; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.notification_alert); /*********** create notification ***********/ final notificationmanager mgr= (notificationmanager)this.getsystemservice(context.notification_service); notification note=new notification(r.drawable.stat_notify_chat, "android illustration status message!", system.currenttimemillis()); // pending intent open after notification click pendingintent i=pendingintent.getactivity(this, 0, new intent(this, notifymessage.class), 0); note.setlatesteventinfo(this, "android illustration notification title", "this android illustration notification message", i); //after uncomment line see number of notification arrived //note.number=2; mgr.notify(notify_me_id, note); } }

activity 2

import android.app.activity; import android.os.bundle; import android.widget.textview; public class notifymessage extends activity { @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); textview txt=new textview(this); txt.settext("activity after click on notification"); setcontentview(txt); } }

android android-notifications

No comments:

Post a Comment