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

提高网站流量原则/网络营销策划书1000字

提高网站流量原则,网络营销策划书1000字,现代示范校建设专题网站,有特色的企业网站目前有三种通知 第一种是普通通知 看看效果 布局什么的太简单了我就不放在上面了给你们看核心的代码就行了 里面的 int notificationID 1; //设置点击通知后的意图Intent intent new Intent(this,NotificationView.class);intent.putExtra("notificationID",noti…

目前有三种通知

 

第一种是普通通知

看看效果

布局什么的太简单了我就不放在上面了给你们看核心的代码就行了 里面的   int notificationID = 1;

//设置点击通知后的意图Intent intent = new Intent(this,NotificationView.class);intent.putExtra("notificationID",notificationID);//塞入pendingIntent  参数解释:1.上下文也就是context 2.请求码(用于意图的请求码) 3.意图(用来启动目标活动的意图) 4.标志(活动启动时使用的标志)PendingIntent pendingIntent = PendingIntent.getActivity(this,0,intent,PendingIntent.FLAG_CANCEL_CURRENT);//获取系统的notification管理服务NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);//现在官方推荐用builder的方式构建Notification,原来是new的方式已经淘汰了。Notification.Builder builder = new Notification.Builder(this);//收到通知时最顶部显示的信息
        builder.setSmallIcon(R.mipmap.ic_launcher);builder.setTicker("Reminder:Meeting starts in 5 minutes");builder.setWhen(System.currentTimeMillis());//下拉顶部看到的详细通知信息 图标通用的builder.setContentTitle("System Alarm"); //设置标题builder.setContentText("Meeting with customer at 3pm.."); //设置内容//设置通知被点击后的意图处理也就是打开某个activity//至于为什么要用pendingIntent ,因为PendingIntent对象可以代表应用程序帮助您在后面的某个时候执行一个动作,而“不用考虑应用程序是否正在运行”
        builder.setContentIntent(pendingIntent);builder.setDefaults(Notification.DEFAULT_SOUND); //设置默认的声音和震动//当然你也可以自定义设置震动
//        builder.setVibrate(new long[]{100,250,100,500}); //设置震动builder.setAutoCancel(true);//设置点击后自动消失也就是取消显示  true:点击后消失;false:点击后不消失;默认是falseNotification notif = builder.build(); //构建 这里注意build方法最低支持minSdkVersion 16manager.notify(notificationID,notif); //notification管理服务发送你所构建的通知  此时你会收到通知

注意里面的builder.setAutoCancel(true); 如果你不想程序自动帮你点击后关闭,而是自己用代码在另一个位置自己去关闭,那么你可以不写这句代码,也可以设置成false,然后关闭代码可以这么写

        //获取服务NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);nm.cancel(getIntent().getIntExtra("notificationID",1)); //关闭显示notificationID为1的通知

切记关闭id与你通知一致的id。

也可以写个方法

/*** 显示普通的通知*/private void showNormalNotify(){Notification.Builder builder = new Notification.Builder(this);builder.setAutoCancel(true); //设置点击玩自动关闭
        builder.setSmallIcon(R.drawable.ic_launcher_background);builder.setLargeIcon(BitmapFactory.decodeResource(getResources(),R.drawable.ic_launcher_foreground));builder.setContentTitle("普通通知");builder.setContentText("普通通知的我的鬼内容");Intent intent = new Intent(Intent.ACTION_VIEW,Uri.parse("http://www.baidu.com"));PendingIntent pendingIntent = PendingIntent.getActivity(this,0,intent,0);builder.setContentIntent(pendingIntent);NotificationManager notifiyManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);notifiyManager.notify(1,builder.build());}

 

第二种折叠式的通知

看看效果

 

写法也是类似只是需要用到红色标注的代码

 /*** 显示折叠式的通知*/@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)private void showZDNotify(){Notification.Builder builder = new Notification.Builder(this);builder.setAutoCancel(true);builder.setSmallIcon(R.drawable.ic_launcher_background);builder.setLargeIcon(BitmapFactory.decodeResource(getResources(),R.drawable.ic_launcher_foreground));builder.setContentTitle("折叠式通知");builder.setContentText("这是折叠式通知");Intent intent = new Intent(Intent.ACTION_VIEW,Uri.parse("http://www.baidu.com"));PendingIntent pendingIntent = PendingIntent.getActivity(this,0,intent,0);builder.setContentIntent(pendingIntent);RemoteViews remoteViews = new RemoteViews(getPackageName(),R.layout.view_fold);Notification notification = builder.build();notification.bigContentView = remoteViews;NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);;notificationManager.notify(1,notification);}

 

第三种是悬挂式通知

看看效果

来看看使用方法

写法也是类似只是需要用到红色标注的代码

 

/*** 显示悬挂式的通知*/private void showXGNotify(){Notification.Builder builder = new Notification.Builder(this);builder.setAutoCancel(true);builder.setSmallIcon(R.drawable.ic_launcher_background);builder.setLargeIcon(BitmapFactory.decodeResource(getResources(),R.drawable.folder));builder.setContentTitle("悬挂式通知");builder.setContentText("这是折叠式通知");Intent intent = new Intent();intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);intent.setClass(this,TestActivity.class);PendingIntent hangPendingIntent = PendingIntent.getActivity(this,0,intent,PendingIntent.FLAG_CANCEL_CURRENT);builder.setFullScreenIntent(hangPendingIntent,true);
        NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);notificationManager.notify(1,builder.build());}

 

Android 5.0后加入了一种新的模式Notification显示等级,共有以下3种

1.VISIBILITY_PUBLIC:任何情况都会显示通知

2.VISIBILITY_PRIVATE:只有在没有锁屏时会显示通知。

3.VISIBILITY_SECRET:在pin、password等安全锁和没有锁屏的情况下才能显示通知

设置非常简单,只要调用setVisibility方法就行了

builder.setVisibility(Notification.VISIBILITY_PUBLIC);

是不是很简单。

好了,好好学习天天向上。 

学习记录,如果有错请指出,谢谢!

 

转载于:https://www.cnblogs.com/woaixingxing/p/7490286.html

http://www.lbrq.cn/news/1074457.html

相关文章:

  • 0539 网站/百度人工服务24小时电话
  • 做网站怎么还用身份证/关键词汇总
  • 任县城乡建设局网站/石家庄
  • 网页设计基础知识试题/seo内容优化是什么
  • 佛山网站建设网站制作公司/seo营销专员
  • 所得税汇算是在12366网站做吗/seo推广排名重要吗
  • 如何获取免费的wordpress/廊坊百度快照优化排名
  • 湛江网站制作公司/bt磁力猪
  • 基金会网站开发方案/公司网页怎么制作
  • 网站改版百度提交/关键词优化武汉
  • 深圳做百度网站/b站推广网站入口mmm
  • 用js做的个人酷炫网站/百度数据指数
  • 网站丢失了怎么办/2022年新闻摘抄简短
  • 描述网站开发的广告词/用今日头条导入自己网站外链
  • 做网站的软件多少钱/站内关键词自然排名优化
  • 河曲县城乡建设管理局网站/seo监控
  • 义乌seo快速排名/深圳优化公司样高粱seo
  • 深圳网站建设科技有限公司/百度广告联系方式
  • 河南网站制作公司哪家好/新乡seo外包
  • 福州企业建站程序/网店代运营骗局
  • ps里新建网站尺寸怎么做/百度指数批量查询
  • 网站服务器开发/温州seo品牌优化软件
  • 网站域名想更换要怎么做/微信管理软件
  • 诸城哪里有做网站的/公司网站排名
  • 做动态网站需要什么软件/宁波优化网站厂家
  • 武汉建网公司网站建设/百度搜索关键词优化方法
  • 河北永生建筑工程网站/网站开发框架
  • 建立自信/汕头seo全网营销
  • 微网站免费制作/趣丁号友情链接
  • 网站建设工作室简介/个人网站的制作模板
  • 秋招笔记-8.3
  • 8.3 滑窗 |栈|阶乘判断
  • Python Seaborn【数据可视化库】 全面讲解
  • Removing Digits(Dynamic Programming)
  • Java试题-选择题(6)
  • JavaScript:Ajax(异步通信技术)