alarmmanager

How to show local notification every hour using service

旧时模样 提交于 2019-12-02 14:54:32
问题 I want to show local notification on every hour or particular seconds using service, I have tried to implement this functionality, but I didn't got success. My code is look like below AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE); Intent notificationIntent = new Intent("android.media.action.DISPLAY_NOTIFICATION"); notificationIntent.addCategory("android.intent.category.DEFAULT"); PendingIntent broadcast = PendingIntent.getBroadcast(this, 100,

极光推送技术原理:移动无线网络长连接

穿精又带淫゛_ 提交于 2019-12-02 14:54:20
移动互联网应用现状 因为手机平台本身、电量、网络流量的限制,移动互联网应用在设计上跟传统 PC 上的应用很大不一样,需要根据手机本身的特点,尽量的节省电量和流量,同时又要尽可能的保证数据能及时到达客户端。 为了解决数据同步的问题,在手机平台上,常用的方法有2种。一种是定时去服务器上查询数据,也叫Polling,还有一种手机跟服务器之间维护一个 TCP 长连接,当服务器有数据时,实时推送到客户端,也就是我们说的 Push。 从耗费的电量、流量和数据送达的及时性来说,Push 都会有明显的优势,但 Push 的实现和维护成本相对较高。在移动无线网络下维护长连接,相对也有一些技术上的难度。本文试图给大家介绍一下我们 极光推送 在 Android 平台上是如何维护长连接。 移动无线网络的特点 因为 IP v4 的 IP 量有限,运营商分配给手机终端的 IP 是运营商内网的 IP,手机要连接 Internet,就需要通过运营商的网关做一个网络地址转换(Network Address Translation,NAT)。简单的说运营商的网关需要维护一个外网 IP、端口到内网 IP、端口的对应关系,以确保内网的手机可以跟 Internet 的服务器通讯。 图片源自 cisco.com. NAT 功能由图中的 GGSN 模块实现。 大部分移动无线网络运营商都在链路一段时间没有数据通讯时,会淘汰

AlarmManager alarm is called immediately when trigger time is in the past

和自甴很熟 提交于 2019-12-02 14:53:19
Below is the code I am using to create alarms when data is pulled from external API. If the time set is in the past, the alarm goes off as soon as it is set(2 second gap). For example if I set the alarm for 8:00 AM, 10th April at 10:00 AM on 11th April(Past time). It starts the alarm as soon as it is set. public static final int ALARM_REQUEST_CODE = 1001; public static AlarmManager alarmManager = (AlarmManager) EHCApplication.getInstance().getApplicationContext().getSystemService(Context.ALARM_SERVICE); public static Intent alarmIntent = new Intent(EHCApplication.getInstance()

Editing scheduled pending intends

风流意气都作罢 提交于 2019-12-02 14:13:49
问题 I wrote an app to turn on/off WiFi at scheduled time choosen before. The way it works is preety simple: Choose time from timepicker, then just add it. Programmatically it gets data from timepicker and sets and alarm. I'd write down a code for my activity and broadcast receiver first, bellow this code I'll write my questions. Don't worry, I put comments inside the code to be more clear to read and understand Wifi.class: public class WiFi extends AppCompatActivity { private final int TEMP

Service pauses on screen lock

ⅰ亾dé卋堺 提交于 2019-12-02 12:43:56
问题 For testing purposes i have made a service that beeps every 1 minute. (No client-server interface yet). It beeps okay when the screen in on, but when it goes to sleep the beeping stops. I am making an application that has to periodically poll the a server for something. For this, I am trying to create a service that'll constantly be running in the background, poll the server every 1 min and then based on the reply from server it shall generate a task bar notification. I have a test activity

setRepeating of AlarmManager not respond within the time indicated

自古美人都是妖i 提交于 2019-12-02 12:06:58
AlarmManager should be repeated every 1 minute, but repeated every 1, 2, 3 or 4 minutes. Since the application I throw AlarmManager public class PacienteApp extends Application { @Override public void onCreate() { AlarmManager gps = (AlarmManager) this.getSystemService(Context.ALARM_SERVICE); Intent i = new Intent(this, GpsReceiver.class); PendingIntent pending = PendingIntent.getBroadcast(this, 0, i, 0); gps.setRepeating(AlarmManager.RTC, System.currentTimeMillis(), 1000 * 60, pending); } } Since BroadcastReceiver call a IntentService. public class GpsReceiver extends BroadcastReceiver {

Alarm Manager with 2 pending intents only 1 works?

风格不统一 提交于 2019-12-02 11:58:41
问题 I have 2 alarms set, one for notifications, and the other one to do some tasks. My problem is that only one alarm seems to work( the notifications service one, the first alarm set). The Other alarm never goes off. Here is my code : Intent myIntent1 = new Intent(getApplicationContext(), NotificationService.class); PendingIntent pendingIntent = PendingIntent.getService(getApplicationContext(), 0, myIntent1, 0); AlarmManager alarmManager1 = (AlarmManager) this.getSystemService(Context.ALARM

set repeated alarm manager for every hour in android

£可爱£侵袭症+ 提交于 2019-12-02 11:24:51
I want to fetch location every hours in android . For that i use alarm manager and set repeated alarm for every hour and just want to write into file after fix time i.e at 8 AM and 12 PM . I got a problem in setting alarm manager , while i set for every one hour but it execute in 1/2 hour . on button click i start service : serviceButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent myIntent = new Intent(AutoMainActivity.this, TrackerService.class); pendingIntent = PendingIntent.getService(AutoMainActivity.this, 0, myIntent, 0); AlarmManager

Android: open activity when alarm clock is done or dismmised

落花浮王杯 提交于 2019-12-02 10:33:45
Every alarm clock that the user set through the phone stock clock has an option of opening another application when the alarm is dismissed or done (I'm not sure if this feature is added in Marshmallow but I have it and I run android M). The default for each alarm is "none" but you're able to pick the mail, weather, music applications etc... I would like to add my application to this list so it'll open directly when the alarm is done. What settings are needed for my application to show up at this list, and how can I set it as the default app for specific alarm (What extra should be specefied)

Run code every day at a specific time - AlarmManager

走远了吗. 提交于 2019-12-02 10:22:12
问题 Currently, I am trying to run a piece of code at a specific time. After some research, I think the correct way to go is to make usage of the AlarmManger . The code should be executed every day at 3 am. If the phone is at 3 am shut down, the code should be executed directly after turning the phone on. I used googled and found a lot of results. But my code isn't working correctly. Yesterday I got a notification. The notification time was 10 pm. But in the code, the time is set to 3 am. I set up