android app notification的用法
2015-06-19 11:19
363 查看
<span style="font-size:18px;">public void showDialog() { Log.i(TAG, " matt-showDialog"); Notification notification = new Notification(); notification.icon = R.drawable.ic_launcher; notification.when = System.currentTimeMillis(); if(notification==null) Log.i(TAG, " matt-notification==null"); else{ String service = Context.NOTIFICATION_SERVICE; mNotification = (NotificationManager)getSystemService(service); String tickerText = "测试Notification"; notification.tickerText = tickerText; notification.flags = Notification.FLAG_AUTO_CANCEL; RemoteViews rv = new RemoteViews(getPackageName(), R.layout.matt); //这里需要自己搞一个xml来显示图片 rv.setTextViewText(R.id.text_content, "hello wrold!"); notification.contentView = rv; Intent intent = new Intent(Intent.ACTION_MAIN); PendingIntent contentIntent = PendingIntent.getActivity(this, 1, intent, 1); notification.contentIntent = contentIntent; mNotification.notify(1, notification); } }</span>
接下来是matt.xml文件
<span style="font-size:18px;"><?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <TextView android:id="@+id/text_content" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="20sp" /> </LinearLayout> </span>
相关文章推荐
- LeetCode_42---Trapping Rain Water
- Android获取的时间转为12小时制
- iOS开发之使用XMPPFramework实现即时通信
- android 自定义标题栏
- 【Unity】Shader编程 基础总结
- 以backlight为例说明hal层调用
- Android实现XML解析技术
- IOS学习笔记16——Core Data
- xcode archive提交到appstore时候出现崩溃的解决方案
- .append(),String.contains("123"),String.format()在android中的运用
- <NSCoding>存储数据 archivedDataWithRootObject unarchiveObjectWithData
- iOS 文件下载断点续传
- 操纵JsonObject的方法
- cocos2dx  混合模式
- Android APK反编译就这么简单 详细解释(简介)
- Objective-C----防御式编程
- iOS去掉字符串两端的空格
- Unity remote 连接不上解决方案
- Android常用控件之FragmentTabHost的使用
- iOS 多线程使用总结(很实用)