android notification處理

public class NotificationDeal
{
   
    private Context myContext;
   
    public NotificationDeal(Context context)
    {
        this.myContext = context;
    }
   
    public void insertNotification(String tickerText,String contentTitle,String contentText)
    {
        String ns = Context.NOTIFICATION_SERVICE;
        NotificationManager mNotificationManager = (NotificationManager) myContext.getSystemService(ns);
        int icon = R.drawable.logo;
        long when = System.currentTimeMillis();
        Notification notification = new Notification(icon, tickerText, when);
        //CharSequence tickerText = "titile";
        //定義下拉通知欄時要展現的內容信息
        //CharSequence contentTitle = "intro_index";
        //CharSequence contentText = "intro";

        Intent notificationIntent = new Intent(myContext, VoiceIdentify.class);

        PendingIntent contentIntent = PendingIntent.getActivity(myContext, 0,notificationIntent, 0);

        notification.setLatestEventInfo(myContext, contentTitle, contentText,contentIntent);

        //用mNotificationManager的notify方法通知用戶生成標題欄消息通知

        mNotificationManager.notify(1, notification);
    }
   
}
發佈了45 篇原創文章 · 獲贊 1 · 訪問量 1萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章