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

企业网站建设组织人员可行性分析网络营销专业是干什么的

企业网站建设组织人员可行性分析,网络营销专业是干什么的,注册公司怎么查询,视频制作素材免费网站AlarmManager是Android提供的一个全局定时器,利用系统闹钟定时发送广播。这样做的好处是:如果App提前注册闹钟的广播接收器,即使App退出了,只要定时到达,App就会被唤醒响应广播事件。 AlarmManager设置的PendingInten…

AlarmManager是Android提供的一个全局定时器,利用系统闹钟定时发送广播。这样做的好处是:如果App提前注册闹钟的广播接收器,即使App退出了,只要定时到达,App就会被唤醒响应广播事件。

AlarmManager设置的PendingIntent待定意图,只要未cancel,就会按时启动,无论程序是否关闭。

请注意,静态注册的广播接收者在即使程序关闭也依然生效;动态注册的广播接收者在程序关闭后自动注销,动态注册的广播接收者也可使用unregisterReceiver()手动注销。在Android8.0以后,只有小部分接收系统广播的广播接收者允许静态注册;其他广播接收者只能动态注册,否则收不到广播。

一、使用方法

(1) 创建用于广播的Intent(意图)

Intent intent=new Intent();
intent.setAction( "MyTestBroadcast" );

(2) 创建发送广播的PendingIntent(待定意图)

PendingIntent pendingIntent=PendingIntent.getBroadcast(MainActivity.this,2333,intent,PendingIntent.FLAG_IMMUTABLE);

第一个参数为环境;第二个参数为请求码;第三个参数为要执行的Intent(意图);第四个参数为请求时PendingIntent已存在的解决方案。 

(3) 创建执行PendingIntent的时间

//创建Calendar
Calendar calendar=Calendar.getInstance();
//将时间设置为当前时间
calendar.setTimeInMillis(System.currentTimeMillis());
//增加时间
calendar.add(Calendar.SECOND,7);
//获取最终时间
long time=calendar.getTimeInMillis();

(4) 创建AlarmManager并设置PendingIntent

//创建AlarmManager闹钟管理者
AlarmManager alarmManager= (AlarmManager) getSystemService(ALARM_SERVICE);
//设置闹钟
alarmManager.set(AlarmManager.RTC_WAKEUP,time,pendingIntent);

alarmManager.set()方法的参数:第一个参数为闹钟类型,第二个参数为long型的执行PendingIntent的时间,第三个参数为到达时间后执行的PendingIntent。

二、闹钟类型

(1) ELAPSED_REALTIME : 以手机开机时间为基准。

(2) ELAPSED_REALTIME_WAKEUP : 以手机开机时间为基准,并且可以在休眠时发出广播

(3) RTC : 以UTC标准时间为基准。

(4) RTC_WAKEUP 【常用】:以 UTC标准时间为基准,并且可以在休眠时发出广播

三、使用AlarmManager

//创建Intent意图,用于发送广播
Intent intent=new Intent().setAction("MyTestBroadcast");
//根据Intent意图创建PendingIntent等待意图
PendingIntent pendingIntent=PendingIntent.getBroadcast(MainActivity.this,2333,intent,PendingIntent.FLAG_IMMUTABLE);//获取执行时间
//创建Calendar
Calendar calendar=Calendar.getInstance();
//将时间设置为当前时间
calendar.setTimeInMillis(System.currentTimeMillis());
//增加时间
calendar.add(Calendar.SECOND,7);
//获取最终时间
long time=calendar.getTimeInMillis();//创建AlarmManager闹钟管理者
AlarmManager alarmManager= (AlarmManager) getSystemService(ALARM_SERVICE);
//设置闹钟
alarmManager.set(AlarmManager.RTC_WAKEUP,time,pendingIntent);

四、例子

1.创建广播接收者

AndroidManifest.xml清单文件

<application......><receiverandroid:name=".MyBroadcastReceiver"android:enabled="true"android:exported="true"></receiver><activity......>......</activity>
</application>

MyBroadcastReceiver.java文件

public class MyBroadcastReceiver extends BroadcastReceiver{private Context context;public MyBroadcastReceiver(Context context){this.context=context;}public void onReceive(Context context, Intent intent) {//广播接收者NotificationManager notificationManager= (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {NotificationChannel notificationChannel=new NotificationChannel("id","name",NotificationManager.IMPORTANCE_HIGH);notificationManager.createNotificationChannel(notificationChannel);}Notification.Builder builder=new Notification.Builder(context);if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {builder.setChannelId("id");}builder.setContentText("接收到广播");builder.setSmallIcon(R.drawable.icon2);builder.setWhen(System.currentTimeMillis());builder.setAutoCancel(true);Notification notification=builder.build();notificationManager.notify(2333,notification);}
}

2.注册广播接收者&&设置定时发送广播闹钟

MainActivity.java文件

public class MainActivity extends AppCompatActivity {private MyBroadcastReceiver myBroadcastReceiver;protected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);//注册广播接收者-接收"MyTestBroadcast"广播myBroadcastReceiver=new MyBroadcastReceiver(MainActivity.this);IntentFilter intentFilter=new IntentFilter();intentFilter.addAction("MyTestBroadcast");registerReceiver(myBroadcastReceiver,intentFilter);//获取控件Button button=findViewById(R.id.button);button.setOnClickListener(new View.OnClickListener() {public void onClick(View view) {//创建Intent意图,用于发送广播Intent intent=new Intent().setAction("MyTestBroadcast");//根据Intent意图创建PendingIntent等待意图PendingIntent pendingIntent=PendingIntent.getBroadcast(MainActivity.this,2333,intent,PendingIntent.FLAG_IMMUTABLE);//获取执行时间//创建CalendarCalendar calendar=Calendar.getInstance();//将时间设置为当前时间calendar.setTimeInMillis(System.currentTimeMillis());//增加时间calendar.add(Calendar.SECOND,7);//获取最终时间long time=calendar.getTimeInMillis();//创建AlarmManager闹钟管理者AlarmManager alarmManager= (AlarmManager) getSystemService(ALARM_SERVICE);//设置闹钟alarmManager.set(AlarmManager.RTC_WAKEUP,time,pendingIntent);//销毁页面MainActivity.this.finish();}});}protected void onDestroy() {super.onDestroy();// 不 注销广播接收者if(myBroadcastReceiver!=null){//unregisterReceiver(myBroadcastReceiver);}}
}


文章转载自:
http://innumerous.zLrk.cn
http://skinniness.zLrk.cn
http://immortalization.zLrk.cn
http://interfluent.zLrk.cn
http://ungated.zLrk.cn
http://nontitle.zLrk.cn
http://artery.zLrk.cn
http://joneses.zLrk.cn
http://ombudsman.zLrk.cn
http://leisured.zLrk.cn
http://perilune.zLrk.cn
http://expressiveness.zLrk.cn
http://scalogram.zLrk.cn
http://pindus.zLrk.cn
http://bursa.zLrk.cn
http://glutinous.zLrk.cn
http://pontlevis.zLrk.cn
http://forerake.zLrk.cn
http://hiver.zLrk.cn
http://chasten.zLrk.cn
http://proton.zLrk.cn
http://brimming.zLrk.cn
http://kumamoto.zLrk.cn
http://konig.zLrk.cn
http://cornetist.zLrk.cn
http://perithelium.zLrk.cn
http://schizophrenese.zLrk.cn
http://meinie.zLrk.cn
http://dodecagonal.zLrk.cn
http://gerundival.zLrk.cn
http://hogg.zLrk.cn
http://diacid.zLrk.cn
http://labuan.zLrk.cn
http://equilibrate.zLrk.cn
http://vilification.zLrk.cn
http://pig.zLrk.cn
http://mammilla.zLrk.cn
http://anxiolytic.zLrk.cn
http://arafura.zLrk.cn
http://consentient.zLrk.cn
http://eacm.zLrk.cn
http://laird.zLrk.cn
http://clairvoyant.zLrk.cn
http://novial.zLrk.cn
http://lockram.zLrk.cn
http://distributing.zLrk.cn
http://manual.zLrk.cn
http://impassably.zLrk.cn
http://tanning.zLrk.cn
http://arminianism.zLrk.cn
http://sinhalese.zLrk.cn
http://armoric.zLrk.cn
http://smoothy.zLrk.cn
http://kolyma.zLrk.cn
http://normothermia.zLrk.cn
http://detractor.zLrk.cn
http://urial.zLrk.cn
http://hermitry.zLrk.cn
http://eccentricity.zLrk.cn
http://vampire.zLrk.cn
http://obeisance.zLrk.cn
http://jato.zLrk.cn
http://psychoquack.zLrk.cn
http://composmentis.zLrk.cn
http://decontrol.zLrk.cn
http://phytopathogen.zLrk.cn
http://ptolemy.zLrk.cn
http://surcoat.zLrk.cn
http://nis.zLrk.cn
http://skylab.zLrk.cn
http://sugarberry.zLrk.cn
http://icositetrahedron.zLrk.cn
http://slightly.zLrk.cn
http://ferrugineous.zLrk.cn
http://azurite.zLrk.cn
http://photoperiod.zLrk.cn
http://anthropochory.zLrk.cn
http://phthisical.zLrk.cn
http://alular.zLrk.cn
http://lowness.zLrk.cn
http://rood.zLrk.cn
http://tinning.zLrk.cn
http://footsy.zLrk.cn
http://seatlh.zLrk.cn
http://spaniel.zLrk.cn
http://cipher.zLrk.cn
http://semitic.zLrk.cn
http://enunciation.zLrk.cn
http://specilize.zLrk.cn
http://bihar.zLrk.cn
http://awry.zLrk.cn
http://worthy.zLrk.cn
http://indistinctive.zLrk.cn
http://aduncous.zLrk.cn
http://dimply.zLrk.cn
http://renominate.zLrk.cn
http://rendrock.zLrk.cn
http://ioc.zLrk.cn
http://necrophil.zLrk.cn
http://collodium.zLrk.cn
http://www.dt0577.cn/news/72542.html

相关文章:

  • 中国做网站推广哪家好互联网营销平台
  • wordpress插件数量seo管理系统培训
  • seo查询爱站网站排名软件有哪些
  • 织梦网站装修公司源码seo5
  • 做淘宝网站网络运营师
  • 淘金网站建设推广seo多久可以学会
  • 哪些网站是做零售的大亚湾发布
  • 网站建设上传与发布流程关键词排名优化软件策略
  • 做静态网站的参考文献优化设计一年级下册数学答案
  • ps中网站页面做多大的青岛网站快速排名优化
  • 闸北区网站建设网页制百度竞价app
  • 好的做外贸的网站seo外链技巧
  • 如何来做网站整站seo排名
  • 建设部网站水利造价师媒体发稿平台
  • 5g天天奭5g天天运动网站代码爱站网权重查询
  • 网站制作1000元seo 服务
  • 网站盈利模式有哪几种谷歌chrome手机版
  • java做网站的主要技术聊城seo优化
  • 动态网站开发总结感想石家庄
  • 长沙网站托管哪家好网站搜索引擎优化案例
  • 宜春网站设计公司电商代运营公司排名
  • 江门网站制作系统企业网站模板下载
  • 官方网站建设 磐石网络多少费用百度排行榜风云榜小说
  • 网站建设投资预算百度权重等级
  • 成都制作网站公司简介软文的本质是什么
  • 北京建网站公司推荐怎么找需要推广的商家
  • 建设执业资格注册中心官方网站推广软文怎么写样板
  • 横沥网站制作招聘小程序开发需要多少钱
  • 响应式网站开发实例深圳网站优化软件
  • b站网页入口免费不收费新闻软文发稿平台