NotificationBarActivity.java :  » App » android-chatty » ru » chatty » app » Android Open Source

Android Open Source » App » android chatty 
android chatty » ru » chatty » app » NotificationBarActivity.java
/* NotificationBarActivity.java
 *
 * Copyright 2011 Aleksey Konovalov
 * All Rights Reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>. 
 * 
 */

package ru.chatty.app;

import android.app.Activity;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

public class NotificationBarActivity extends Activity {

  private static final int NOTIFY_ID = 1;

  @Override  
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
//      setContentView(R.layout.main);
      NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); 
      int icon = android.R.drawable.sym_action_email;
      CharSequence tickerText = "Hello World!";
      long when = System.currentTimeMillis();
      Notification notification = new Notification(icon, tickerText, when);
      Context context = getApplicationContext(); 
      CharSequence contentTitle = "Habrahabr";
      CharSequence contentText = "  ";
      Intent notificationIntent = new Intent(this, NotificationBarActivity.class);
      PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); //    UPD  
      notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent); //          
      mNotificationManager.notify(NOTIFY_ID, notification); //          ID
    }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.