I have a activity A, it register AlarmManager to trigger another BroadcastReceiver B. When time is reached, onReceive() of B will be called, and start another activity C. A may be closed when C is started.
If you’re looking to speed up deployed InTouch applications, one of the best ways is to turn on window caching. At a client site, we chose to turn on high-priority caching with 50% RAM available, and turned on visited window caching with 40% memory availability.
My problem is: - C don't know the pendingIntent in A, how can I call alarmManager.cancel(pendingIntent) in C?- Or, how can I pass pendingIntent from A to B to C?
Pls help.
4 Answers
In my application I created a static method that returned the PendingIntent
required for the AlarmManager
, and then I can call it from any class. If you have a PendingIntent
that doesn't change between times it is called this can work for you. For example, I have:
And I can just call that from any class to get the same PendingIntent
.
It would be far easier to manage the Alarm and its intent in a singleton service than to try to pass it from activity to activity, and far less brittle (you could introduce Activity D somewhere in the middle without having to daisy chain the intent further).
You can register a broadcast receiver in A to listen for a custom action that is broadcasted when C is started
In Activity A
register the receiver
In Activity C call
try it! make use of the messaging system for your good :D
To cancel/destroy all the services which you have generated, then generally you need the same 'pendingInetent' and 'AlarmManager' variable which you have used for starting those services, for example if your previous variable is am_mngr and pndngInt then use it like this in your stopservice method.
Not the answer you're looking for? Browse other questions tagged androidalarmmanagerandroid-pendingintent or ask your own question.
I have an installation which has two SCADA (Intouch) HMIs and I want to save the data in an SQL Server database which will be in another computer. To be as sure as possible that I have an operating database I'm going to set a SQL Server mirroring. So I will have 2 SQL server databases with a distributor. About this I don't have any doubt. To make it easy to understand I've made an image with the architecture of the system.
My doubt is how do I configure the Alarm DB Logger to make it point, automatically, to the secondary database in case that the principal database is down for any unknown failover.
PS: I don't know if it's even possible.
2 Answers
Configure it the database in Automatic failover. The connection are handled automatically in case of a failover. Read on Mirroring EndPoints
The below Links should have more than enough information.
The AlarmDBLogger reads its configuration from the registry, so you could try the following:
![Stop Stop](https://okmgcs.km.invensys.com/library/KPKA/migration/t00262808.png)
- Stop AlarmLogger
- Change ServerName in registry [HKLM].[Software].[Wonderware].[AlarmLogger].[SQLServer]
- Start AlarmLogger
But what about the two InTouch-nodes? What if one of those fails? You would have to make sure one of them logs alarms, and that they don't log duplicates!
The standard controls and activex for alarms use a specific view in the alarm database. You cannot change that behaviour, but you can script a server change in InTouch or System Platform.
Keep in mind that redundancy needs to be tested, and should only be implemented if 100% uptime is necessary. In many cases you will be creating new problems to solve instead of solving an actual problem.