当前位置: 首页 > news >正文

网上商城开发设计/seo百度刷排名

网上商城开发设计,seo百度刷排名,西安网站建设制作价格低,福州网站建设http://blog.csdn.net/furongkang/article/details/6900338 Notification是一种让你的应用程序在不使用Activity的情况下警示用户,Notification是看不见的程序组件警示用户有需要注意的事件发生的最好途径。 作为UI部分,Notification对移动设备来说是最…

http://blog.csdn.net/furongkang/article/details/6900338

?Notification是一种让你的应用程序在不使用Activity的情况下警示用户,Notification是看不见的程序组件警示用户有需要注意的事件发生的最好途径。

作为UI部分,Notification对移动设备来说是最适合不过的了。用户可能随时都带着手机在身边。一般来说,用户会在后台打开几个程序,但不会注意它们。在这样的情形下,当发生需要注意的事件时,能够通知用户是很重要的。

Notification由NotificationManger统一管理,目前包含的能力有:

?创建一个状态条图标。

?

?在扩展的状态条窗口中显示额外的信息(和启动一个Intent)。

?

?闪灯或LED。

?

?电话震动。

?

?发出听得见的警告声(铃声,保存的声音文件)。

自定义Notification效果图:

???

?

自定义的布局文件:

[html]?view plaincopy
  1. ??
  2. ??xmlns:android="http://schemas.android.com/apk/res/android"??
  3. ??android:orientation="vertical"??
  4. ??android:layout_width="match_parent"??
  5. ??android:layout_height="match_parent">??
  6. ?
  7. ??android:id="@+id/tv_rv"??
  8. ??android:layout_width="wrap_content"??
  9. ??android:layout_height="wrap_content"??
  10. ??android:text="haha"??
  11. ?/>???
  12. ??style="@android:style/Widget.ProgressBar.Horizontal"??
  13. ??android:id="@+id/pb_rv"??
  14. ??android:layout_width="wrap_content"??
  15. ??android:layout_height="wrap_content"??
  16. ?/>???
  17. ??


创建Notification:

[java]?view plaincopy
  1. public?class?CustomNotificationActivity?extends?Activity?{??
  2. ????NotificationManager?notificationManager;??
  3. ????@Override??
  4. ????public?void?onCreate(Bundle?savedInstanceState)?{??
  5. ????????super.onCreate(savedInstanceState);??
  6. ????????setContentView(R.layout.main);??
  7. ????????//获取到系统的notificationManager??
  8. ????????notificationManager?=??(NotificationManager)?getSystemService(Context.NOTIFICATION_SERVICE);??
  9. ????}??
  10. ??????
  11. ????public?void?click(View?view?){??
  12. ????????//实例化一个notification???
  13. ?????????String?tickerText?=?"IP号码?设置完毕";??
  14. ?????????long?when?=?System.currentTimeMillis();??
  15. ?????????Notification?notification?=?new?Notification(R.drawable.icon,?tickerText,?when);??
  16. ???????????
  17. ?????????//不能手动清理??
  18. ?????????//notification.flags=?Notification.FLAG_NO_CLEAR;??
  19. ?????????//添加音乐??
  20. ?????????//notification.sound?=?Uri.parse("/sdcard/haha.mp3");???
  21. ???????????
  22. ?????????//设置用户点击notification的动作???
  23. ?????????//?pendingIntent?延期的意图???
  24. ?????????Intent?intent?=?new?Intent(this,Bactivity.class);??
  25. ?????????PendingIntent?pendingIntent??=?PendingIntent.getActivity(this,?0,?intent,?0);??
  26. ?????????notification.contentIntent?=?pendingIntent;??
  27. ??????????
  28. ?????????//自定义界面???
  29. ?????????RemoteViews?rv?=?new?RemoteViews(getPackageName(),?R.layout.noti_layout);??
  30. ?????????rv.setTextViewText(R.id.tv_rv,?"我是自定义的?notification");??
  31. ?????????rv.setProgressBar(R.id.pb_rv,?80,?20,?false);??
  32. ?????????notification.contentView?=?rv;??
  33. ???????????
  34. ?????????//把定义的notification?传递给?notificationmanager???
  35. ?????????notificationManager.notify(0,?notification);??
  36. ????}??
  37. }??

相关文章:

  • 怎么网站后台/西安网站建设制作
  • 怎么网站后台/西安网站建设制作