[英]Ads Changing for every 3-5 seconds in an activity of Android Application
I am developing one android application in which i have implemented the 10 ads in one activity using web services. 我正在开发一个Android应用程序,其中我使用Web服务在一个活动中实现了10个广告。 Now, i want to give the timeline for changing those ads for every 3 to 5 seconds. 现在,我想给出每3至5秒更改这些广告的时间表。 Please help with the sample code/links. 请帮助您提供示例代码/链接。 Thanks in advance. 提前致谢。
just working with Countdown timer 只是使用倒数计时器
Schedule a countdown until a time in the future, with regular notifications on intervals along the way. 安排倒计时,直到将来的某个时间,并在整个过程中定期通知。 Example of showing a 30 second countdown in a text field: 在文本字段中显示30秒倒计时的示例:
new CountdownTimer(30000, 1000) {
public void onTick(long millisUntilFinished) {
mTextField.setText("seconds remaining: " + millisUntilFinished / 1000);
}
public void onFinish() {
mTextField.setText("done!");
}
}.start();
TimerTask.schedule()
will solve your problem. TimerTask.schedule()
将解决您的问题。
Please google for more information. 请谷歌了解更多信息。
You should use AlarmManager or Timer service for doing it it is execute in every 3-5 second. 您应该使用AlarmManager或Timer服务来执行它每3-5秒执行一次。
I have also make a function of using alarm manager auto logout if user ideal for 5 min then it is logout. 如果用户理想5分钟然后注销,我还可以使用警报管理器自动注销功能。 public static void autoLogOut(Context context) { public static void autoLogOut(Context context){
MyAlarmService.mContext = context;
Intent myIntent = new Intent(context, MyAlarmService.class);
pendingIntent = PendingIntent.getService(context, 0, myIntent, 0);
AlarmManager alarmManager = (AlarmManager) context
.getSystemService("alarm");
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis());
calendar.add(Calendar.SECOND, (5 * 60));
alarmManager.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(),
pendingIntent);
// Toast.makeText(context, "Start Alarm", Toast.LENGTH_LONG).show();
}
it is execute after if user ideal for 5 min. 如果用户理想5分钟后执行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.