Android为TV端助力 自定义通知栏
package com.example.mvp;
import cn.ljuns.temperature.view.TemperatureView;
import presenter.ILoginPresenter;
import presenter.LoginPresenterCompl;
import android.os.Bundle;
import android.app.Activity;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.graphics.drawable.BitmapDrawable;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.VelocityTracker;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;
import android.widget.EditText;
import android.widget.PopupWindow;
import android.widget.RemoteViews;
import android.widget.Toast;
import android.app.ActionBar.LayoutParams;
import android.content.Context;
import android.content.Intent;
public class MainActivity extends Activity implements ILoginView{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_main);
Notification notification = new Notification();
//设置图标,后面的自定义布局的图片会覆盖它,但还是得设置,不然不会显示到通知栏
notification.icon = R.drawable.ic_launcher;
notification.tickerText = "hello I am gougou";
notification.when = System.currentTimeMillis();
notification.flags = Notification.FLAG_AUTO_CANCEL;
//传入当前项目的包名,和你通知栏上要显示的自定义布局的ID
RemoteViews remoteViews = new RemoteViews(getPackageName(), R.layout.activity_amain);
//下面都是设置通知栏布局里面控件的属性
remoteViews.setImageViewResource(R.id.imageView1, R.drawable.hot);
remoteViews.setTextColor(R.id.textView1, Color.RED);
remoteViews.setTextViewText(R.id.textView1, "hello I am 小篮子");
remoteViews.setTextViewTextSize(R.id.textView1, 1, 15);
// PendingIntent有4种flag.
// - FLAG_ONE_SHOT 只执行一次
// - FLAG_NO_CREATE 若描述的Intent不存在则返回NULL值
// - FLAG_CANCEL_CURRENT 如果描述的PendingIntent已经存在,则在产生新的Intent之前会先取消掉当前的
// - FLAG_UPDATE_CURRENT 总是执行,这个flag用的最多
PendingIntent pendingIntent = PendingIntent.getActivity(
this, 0, new Intent(this,AMainActivity.class),
PendingIntent.FLAG_UPDATE_CURRENT);
remoteViews.setOnClickPendingIntent(R.id.textView1, pendingIntent);
notification.contentView = remoteViews;
notification.contentIntent = pendingIntent;
NotificationManager manager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
manager.notify(1, notification);
}
R.layout.activity_amain 的布局
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".AMainActivity" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
/>
<TextView
android:id="@+id/textView1"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:clickable="true"
/>
<TextView
android:id="@+id/textView2"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
/>
</LinearLayout>
Android为TV端助力 自定义通知栏的更多相关文章
- Android为TV端助力:自定义view之太阳
先看效果图 package com.hhzt.iptv.lvb_w8.view; import android.content.Context;import android.graphics.Canv ...
- Android为TV端助力 自定义动画
android自定义动画注意是继承Animation,重写里面的initialize和applyTransformation,在initialize方法做一些初始化的工作,在applyTransfor ...
- Android为TV端助力 自定义activity
今天公司有个需要需要自动弹出界面,而dialog又不符合要求,所以自定义的一个activity的样式 首先在androidmainfest.xml上注册你的activity <activity ...
- Android为TV端助力 自定义view中findViewById为空的解决办法
网上说的都是在super(context, attrs);构造函数这里少加了一个字段, 其实根本不只这一个原因,属于view生命周期的应该知道,如果你在 自定义view的构造函数里面调用findVie ...
- Android为TV端助力 deep link(深度链接)与自定义协议!
此自定义仅供参考! 首先打开androidManifest.xml 在MainActivity中添加如下内容: <activity android:name=".MainActivit ...
- Android为TV端助力 最简单的自定义圆点view
首先创建一个选择器,用来判断圆点状态,可以根本自己的需求改 <selector xmlns:android="http://schemas.android.com/apk/res/an ...
- Android为TV端助力 转载:android自定义view实战(温度控制表)!
效果图 package cn.ljuns.temperature.view; import com.example.mvp.R; import android.content.Context;impo ...
- Android为TV端助力(转载)
作者地址http://www.jianshu.com/u/63915ef020e2 针对Android Tv的自定义RecyclerView 作者 wenju_song 关注 2016.12.09 1 ...
- Android为TV端助力之WebView开发踩坑一
在Android清单配置文件里面 自定义application时,在4.4系统上面不能加上一个属性,见下图 否则界面将不会显示任何数据,在更高或者更低的系统上面没有测试!
随机推荐
- Python - 使用Pylint检查分析代码
1-简介 Home Page : https://www.pylint.org/ 检查语法错误,是否遵守编码风格标准.潜在的问题等: 支持自定义配置:例如显示或隐藏特定的警告,并且可以通过编写插件来添 ...
- Kubernetes集群搭建之Master配置篇
本次系列使用的所需部署包版本都使用的目前最新的或最新稳定版,安装包地址请到公众号内回复[K8s实战]获取 今天终于到正题了~~ 生成kubernets证书与私钥 1. 制作kubernetes ca证 ...
- 利用vi编辑器创建和编辑正文文件(二)
末行模式下的命令 1. w:写文件,将编辑的内容保存到文件系统. 2. w!:如果只读文件,强制写入系统. 3. q!:退出vi,但文件内容修改的话,系统要提示是否 ...
- Quartz的使用案例
一.介绍 项目中的调度任务可以使用Quartz任务调度框架 1.Job接口:这个接口里面只定义了一个方法,excute void execute(JobExecutionContext context ...
- vue webpack配置解决跨域问题
现在基本项目都是实行前后端分离的原则,不管是ng 或者是vue 在开发中都无法避免跨域的这个问题 本人刚上手第一个vue项目,在调用api的时候出现了跨域的这个问题 这是封装好一个简单的post 请求 ...
- input01.sh: line 11: warning: here-document at line 4 delimited by end-of-file (wanted `EOF') input01.sh: line 12: syntax error: unexpected end of file
写了个脚本用cat>>EOF报错如下: input01.sh: line 11: warning: here-document at line 4 delimited by end-of- ...
- Selenuim自动化测试模型
本章内容: 概念介绍 自动化测试模型 一.概念 自动化测试库.框架.工具之间的区别: 库是由代码集合成的一个产品,供程序员调用,面向对象的代码组织形成的库叫类库,面向过程的代码组织形成的库叫函数库. ...
- CentOS7.0小随笔——运行级别
一.Linux运行级别(通用) 0:关机(halt) 1:单用户模式(无需用户名和密码的登录,用于紧急维护系统时用,类似于Windows中的安全模式) 2:不启用网络功能的多用户模式 3:启用网络功能 ...
- bash内置命令mapfile:读取文件内容到数组
bash提供了两个内置命令:readarray和mapfile,它们是同义词.它们的作用是从标准输入读取一行行的数据,然后每一行都赋值给一个数组的各元素.显然,在shell编程中更常用的是从文件.从管 ...
- 分布式系统监视zabbix讲解八之自动发现/自动注册--技术流ken
自动发现(LLD) 概述 自动发现(LLD)提供了一种在计算机上为不同实体自动创建监控项,触发器和图形的方法.例如,Zabbix可以在你的机器上自动开始监控文件系统或网络接口,而无需为每个文件系统或网 ...