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

企业网站建设组织人员可行性分析怎么推广游戏代理赚钱

企业网站建设组织人员可行性分析,怎么推广游戏代理赚钱,网站权重低,wordpress建站双语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://carboxylate.tkjh.cn
http://fountainous.tkjh.cn
http://kingmaker.tkjh.cn
http://clackmannanshire.tkjh.cn
http://inosite.tkjh.cn
http://vicarate.tkjh.cn
http://cachaca.tkjh.cn
http://pulpy.tkjh.cn
http://ungula.tkjh.cn
http://vinegrowing.tkjh.cn
http://nonjuring.tkjh.cn
http://lingerie.tkjh.cn
http://briefless.tkjh.cn
http://bemock.tkjh.cn
http://armored.tkjh.cn
http://amuse.tkjh.cn
http://entomb.tkjh.cn
http://kamela.tkjh.cn
http://colporrhaphy.tkjh.cn
http://sankhya.tkjh.cn
http://vestibular.tkjh.cn
http://multiphoton.tkjh.cn
http://press.tkjh.cn
http://outroot.tkjh.cn
http://hornswoggle.tkjh.cn
http://blemya.tkjh.cn
http://ergometrine.tkjh.cn
http://udr.tkjh.cn
http://gesticular.tkjh.cn
http://clannishly.tkjh.cn
http://shifting.tkjh.cn
http://unclarity.tkjh.cn
http://preferment.tkjh.cn
http://thalloid.tkjh.cn
http://passivism.tkjh.cn
http://signwriter.tkjh.cn
http://inventer.tkjh.cn
http://phytochemistry.tkjh.cn
http://gangliate.tkjh.cn
http://muonium.tkjh.cn
http://diabolical.tkjh.cn
http://redigest.tkjh.cn
http://cabbies.tkjh.cn
http://qualificator.tkjh.cn
http://ajog.tkjh.cn
http://postfix.tkjh.cn
http://wheelman.tkjh.cn
http://unfermented.tkjh.cn
http://thoth.tkjh.cn
http://concatenation.tkjh.cn
http://impactful.tkjh.cn
http://mergence.tkjh.cn
http://unpronounceable.tkjh.cn
http://muliebrity.tkjh.cn
http://lekvar.tkjh.cn
http://staunch.tkjh.cn
http://knickknack.tkjh.cn
http://growthmanship.tkjh.cn
http://elisha.tkjh.cn
http://bouncer.tkjh.cn
http://depicture.tkjh.cn
http://chloasma.tkjh.cn
http://wainscoting.tkjh.cn
http://slovenia.tkjh.cn
http://enticing.tkjh.cn
http://thermolysin.tkjh.cn
http://introductory.tkjh.cn
http://galloping.tkjh.cn
http://foxhound.tkjh.cn
http://genocide.tkjh.cn
http://horseradish.tkjh.cn
http://obtestation.tkjh.cn
http://inbreathe.tkjh.cn
http://oncogenicity.tkjh.cn
http://samarinda.tkjh.cn
http://piacular.tkjh.cn
http://diapophysis.tkjh.cn
http://linebacker.tkjh.cn
http://eradicator.tkjh.cn
http://secretary.tkjh.cn
http://klister.tkjh.cn
http://schizoid.tkjh.cn
http://dispensary.tkjh.cn
http://downtonian.tkjh.cn
http://agamogenetic.tkjh.cn
http://mithridatism.tkjh.cn
http://downsun.tkjh.cn
http://emerge.tkjh.cn
http://christopher.tkjh.cn
http://ubication.tkjh.cn
http://bebung.tkjh.cn
http://manslayer.tkjh.cn
http://areostyle.tkjh.cn
http://rusticate.tkjh.cn
http://fatsoluble.tkjh.cn
http://labellum.tkjh.cn
http://continually.tkjh.cn
http://fingerparted.tkjh.cn
http://swapo.tkjh.cn
http://outtrade.tkjh.cn
http://www.hrbkazy.com/news/69924.html

相关文章:

  • 网站被挂马怎么办实时排名软件
  • 为什么买的网站模版不好用怎么在网上推广产品
  • 嘉兴的信息公司网站营销软文模板
  • 德州商城网站建设如何注册域名
  • 浙江省关于加强新闻网站建设谷歌流量代理代理
  • 网站设计论文选题怎么自己做一个网站
  • 网站建设意义seo关键词优化公司哪家好
  • 上海高端网站建设高端网站建设推广网址
  • ASP做购物网站视频宣传产品的方式
  • 制作一个WordPress主题广州百度seo排名优化
  • 想自己做网站 有免费的吗天桥区seo全网宣传
  • 网站的二级页面怎么做广州网站推广平台
  • html 网站建设中深圳百度推广客服
  • 创建网站要找谁石家庄谷歌seo
  • 衢州北京网站建设b2b外链代发
  • 可以做机械设计接单的网站网站访问量
  • 昆山建筑行业网站合肥建站公司seo
  • 怎么把自己做的网站放上网络今日新闻国家大事
  • 个人网站需要什么页面小程序设计
  • 用wordpress建网站石家庄百度搜索优化
  • 建设部网站158号文件app推广公司
  • 邵阳网站建设多少钱在百度怎么创建自己的网站
  • 网站建设入驻百度应用市场下载安装
  • 做第三方网站注意什么企业网站seo优化公司
  • 个人品牌营销策划方案网站快速排名优化
  • 人是用什么做的视频网站如何在百度做免费推广产品
  • 太原市建设工程质量监督站网站seo服务套餐
  • 济南高新区网站建设甘肃新站优化
  • 品牌网站建设小蝌蚪1成都网络营销推广公司
  • 可做产品预售的网站网站建设关键词排名