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系统上面不能加上一个属性,见下图 否则界面将不会显示任何数据,在更高或者更低的系统上面没有测试! 
随机推荐
- node的安装及基本使用!
			一.node的基本安装和使用 1.什么是node.js 答:node.js是JavaScript运行环境.实际上它是Google V8引擎进行了封装.V8引擎执行JavaScript的速度非常的 快 ... 
- redis安装以及安全配置
			redis安装以及安全配置 1. 安装 sudo apt-get install redis-server 使用which查询redis执行体安装路径: which redis-server #/us ... 
- Elasticsearch基础教程分享
			基础及相关资料 首先我们先了解一下什么是Elastisearch,Elasticsearch(简称es)是一个基于Lucene库的搜索引擎.它提供了一个分布式.支持多租户的全文搜索引擎,具有HTTP ... 
- 使用C# (.NET Core) 实现简单工厂(Simple Factory) 和工厂方法设计模式 (Factory Method Pattern)
			本文源自深入浅出设计模式. 只不过我是使用C#/.NET Core实现的例子. 前言 当你看见new这个关键字的时候, 就应该想到它是具体的实现. 这就是一个具体的类, 为了更灵活, 我们应该使用的是 ... 
- 课程回顾-Neural Network & Deep Learning
			为什么深度学习发展了数据计算算法发展Logistics RegressionNumpyreshape的计算代价很小,所以你不确定数据维度的时候都可以放上一些解决潜在bug的trick做了归一化之后梯度 ... 
- java 中文乱码的解决方法
			1. 这方法行之有效,但是谨慎用,它会作用服务器.超链接中带有的中文字符,<a class="add" href = "system/showDataAdd.act ... 
- Unity3D热更新之LuaFramework篇[02]--用Lua创建自己的面板
			在上篇文章 Unity3D热更新之LuaFramework篇[01]--从零开始 中,我们了解了怎么获得一个可用的LuaFramework框架. 本篇将我会先介绍一下如何配置Lua开发环境,然后分析在 ... 
- 怎么样使用CLion调试分析MySQL Server
			由于在写MySQL日志订阅服务时候,需要确定在什么event之后保存position,所以就开始研究MySQL的源码,刚开始采用最原始的打印输出的方式去调试,然后每次改完编译运行,效率好低,让我很绝望 ... 
- c# Console application Open/Get Url by Browser
			C# url 用 浏览器打开.C#获取浏览器的url static void Main(string[] args) { string file = @"C:\Users\Hero\Desk ... 
- ES6 系列之我们来聊聊装饰器
			Decorator 装饰器主要用于: 装饰类 装饰方法或属性 装饰类 @annotation class MyClass { } function annotation(target) { targe ... 
