Andorid Notification--不用启动Activity的通知
来源:互联网 发布:淘宝商品带广告标志 编辑:程序博客网 时间:2024/06/10 22:00
不启动Activity的通知,我目前得到的方法得益于对RemoteView的使用:
代码如下:
noti_layout.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="3dp"
>
<ImageView android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginRight="10dp"
/>
<TextView android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:textColor="#000"
/>
</LinearLayout>
...........................................
java部分代码如下:
private void MakeNotification2() {
String tickerText = "tickerText";
NotificationManager NoteManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(R.drawable.icon, tickerText, System.currentTimeMillis());
RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.noti_layout);
contentView.setImageViewResource(R.id.image, R.drawable.icon);
contentView.setTextViewText(R.id.text, "Hello, this message is in a custom expanded view");
notification.contentView = contentView;
Intent notificationIntent = new Intent(this, RemoteViews.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
notification.contentIntent = contentIntent;
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notification.defaults |= Notification.DEFAULT_SOUND;
NoteManager.notify(id++, notification);
}
- Andorid Notification--不用启动Activity的通知
- Andorid Notification--不用启动Activity的通知
- activity间的动画,系统通知nOTIFICATION
- Activity之Notification(通知)
- android点击系统通知Notification,进入指定的activity
- Android -- Notification,如何向通知栏发送通知,点击通知开启相应的Activity
- Andorid的Activity的四种启动模式详解
- notification栏增加常驻通知以及开机启动的处理
- Notification通知的详解
- Notification通知的使用
- 使用一个Notification启动Activity
- notification 点击响应 以及启动activity的坑
- Android中使用Notification并通过点击Notification启动启动通知详细Activity,点击返回键和按钮返回主界面
- 通知栏通知:Notification的实现
- Notification消息通知 通知栏的实现
- android通知栏的消息通知(Notification)
- Andorid Activity的本质是什么
- Android Notification多个通知跳转Activity总会被最后一个替换的问题
- android 进阶
- 解决JS弹出新窗口被浏览器阻止的解决方案
- C#如何让模板列中的控件居中显示?
- GLUT总结
- .NET程序不需要受SVN版本控制的文件类型
- Andorid Notification--不用启动Activity的通知
- HDU 1234 开门人和关门人
- android的日历制作(网址)
- 函数指针与软件设计--------回调函数
- sql server中update会加行锁还是表锁?
- DWR续
- 用javascript程序绘制的矢量图
- mysql show processlist详解
- sql server附加数据库时数据库显示绝对路径