public class SimpleNotification extends Activity {        private NotificationManager mNotificationManager;    private int SIMPLE_NOTFICATION_ID;         /** Called when the activity is first created. */     @Override     public void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.main);                 mNotificationManager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);       final Notification notifyDetails = new Notification(R.drawable.android,"New Alert, Click Me!",System.currentTimeMillis());                Button start = (Button)findViewById(R.id.notifyButton);         Button cancel = (Button)findViewById(R.id.cancelButton);                 start.setOnClickListener(new OnClickListener() {                        public void onClick(View v) {                                             Context context = getApplicationContext();               CharSequence contentTitle = "Notification Details...";               CharSequence contentText = "Browse Android Official Site by clicking me";               Intent notifyIntent = new Intent(android.content.Intent.ACTION_VIEW,Uri.parse("http://www.android.com"));               PendingIntent intent =                  PendingIntent.getActivity(SimpleNotification.this, 0,                  notifyIntent, android.content.Intent.FLAG_ACTIVITY_NEW_TASK);                              notifyDetails.setLatestEventInfo(context, contentTitle, contentText, intent);               mNotificationManager.notify(SIMPLE_NOTFICATION_ID, notifyDetails);            }         });                 cancel.setOnClickListener(new OnClickListener() {                        public void onClick(View v) {                              mNotificationManager.cancel(SIMPLE_NOTFICATION_ID);            }         });     } } //hello word级别的例子。

更多相关文章

  1. android aidl使用小例子
  2. Android学习札记36:一个关于onSaveInstanceState ()方法的例子
  3. android binder c++层-客户端(c++) 调用 服务端(c++) 例子
  4. android上实现语音识别,基于google的语音识的简单例子.
  5. 如何导入android 自带的例子
  6. Android Toast 例子
  7. Android 实现旋转键盘的例子

随机推荐

  1. 记录一下我的Android学习过程-第一课
  2. Android(安卓)P 开发者预览版 · 操作指
  3. Android(安卓)真的能跨平台吗?(翻译)
  4. android Java开发设计模式及在android中
  5. 腾讯优测优分享 | Android性能测试工具化
  6. 将程序安装到SD卡
  7. Android单元测试——初探
  8. Android支持Perl
  9. Android实现分享(Share)功能
  10. Android基础 : Android(安卓)Service