'Cause of BookmarksOverflow...
First things first - why you should be using an Alarm and not a service
- Basic set up
- One shot alarm
- AlarmManager Android Every Day
- ! setup : Background service schedule - no wake lock but start from here
If the updates will occur while your application is running, you can use a Timer, as suggested in other answers, or the newer ScheduledThreadPoolExecutor.
If your application will update even when it is not running, you should go with the AlarmManager
[from here]- Google presentation - page 21 (see also p.26 for enabling/disabling receiver declared in manifest. Also very good discussion here - see the comments (by me mostly))
- ScheduledExecutorService
- Location polling ( commonsguy + fork )
- WakefulIntentService
- Reschedule alarms
- startForeground
- Android Regular GPS Polling in Service
- Alarm manager launching a service (which starts a thread) - and why NEVER use it
- repeat a task with a time delay - using Handler.postDelayed
Btw it is impossible to have anything run on install of the app (see comments here) - and LocalBroadcastManager is not applicable here.
Intent resolution
Cf : Intents can be divided into two groups:
Explicit intents designate the target component by its name (the component name field, mentioned earlier, has a value set). Since component names would generally not be known to developers of other applications, explicit intents are typically used for application-internal messages — such as an activity starting a subordinate service or launching a sister activity.
Implicit intents do not name a target (the field for the component name is blank). Implicit intents are often used to activate components in other applications.
Android delivers an explicit intent to an instance of the designated target class. Nothing in the Intent object other than the component name matters for determining which component should get the intent.
Apparently this component must be declared in some manifest :
The name of the component that should handle the intent. This field is a ComponentName object — a combination of the fully qualified class name of the target component (for example "com.example.project.app.FreneticActivity") and the package name set in the manifest file of the application where the component resides (for example, "com.example.project"). The package part of the component name and the package name set in the manifest do not necessarily have to match.
And on FLAG_UPDATE_CURRENT
Last edited : 2013.03.30 14.45 UTC
No comments:
Post a Comment