Danny,
According to this:
http://developer.android.com/reference/android/content/Intent.html#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE
The extra data EXTRA_CHANGED_PACKAGE_LIST contains a list of packages
whose availability changed. The extra data EXTRA_CHANGED_UID_LIST
contains a list of uids of packages whose availability changed. *Note
that the packages in this list do not receive this broadcast.*
So you might want to run some tests before relying on this broadcast.
I see that Mark Murphy submitted a documentation bug for this:
http://code.google.com/p/android/issues/detail?id=8485
-- Kostya
02.02.2011 14:31, Danny S. пишет:
Today I read this on googles documentation:
Broadcast Receivers listening for "boot completed"
The system delivers the ACTION_BOOT_COMPLETED broadcast before the
external storage is mounted to the device. If your application is
installed on the external storage, it can never receive this
broadcast.
I don't know why it worked in past, cause I used the same device
(emulator) with "sdcard" all the time, but this seems to be the reason
why this broadcast is never received. Now I have 2 possibilities:
1. remove the possibility to install the app on external storage (I
wanted to support App2SD...). Then the broadcast should be received.
2. find another indicator to start my service, e.g.
ACTION_EXTERNAL_APPLICATIONS_AVAILABLE (I prefer this, are you with
me?)
3. Do you have an other idea?
Detailled infos:
http://developer.android.com/guide/appendix/install-location.html
What would you do?
Thanks a lot!
-Danny
On Feb 1, 11:40 am, "Danny S."<[email protected]> wrote:
OMG, today I determined, that my "BootReceiver" is not called
again :'( But I changed nothing in relation with this :( it looks like
an issue to me. I don't do anything in the onReceive yet, only log out
something. This morning it worked very well then I started to
implement code to start my applications service within the receiver.
That worked very well. I used the context.getApplicationContext() to
start the Service. This worked for me, then I tried to change to start
the service with context instead of application context. From this
moment on I've seen no output for onReceive. The broadcast receiver is
never called when the device booted. I build it back to version with
only log output implementation in the onReceive method. But I still
dont get it to work again. I tried to use a completely new created
emulator, but nothing changed :-( I don#t think I am doing something
wrong here, cause I got it to work in past...
-Danny S.
On Jan 27, 4:33 pm, "Danny S."<[email protected]> wrote:
Hi together,
using a second receiver worked for me:
...
<receiver android:name=".AlertReceiver" />
<!-- only for device is booted detection: -->
<receiver android:name=".BootedReceiver">
<intent-filter>
<action
android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
...
I am confused doing it this way. I would have preferred using only one
receiver for handling corresponding actions but it seems this is the
only way... Maybe it has to be like this, but somebody would explain
to me ;-)
Thanks!
-DannyS.
On 27 Jan., 16:19, "DannyS."<[email protected]> wrote:
Kostya,
yeah, I am with you and think my AndroidManifest looks correct. I
figured out too, that all data get lost when "Wipe user data" is
enabled. I started the emulator always without "Wipe user data" but it
does not work. Maybe it is an emulator problem... I can try to figure
out on my real device and show up a notification with information
about intent's action when onReceive() is called.
I temporery implemented notification output and tested it on emulator.
One for boot action and one for any other. In any case there should be
a notification but when I restart the emulator nothing happened...
onReceive is not called. As said I'll try with my real device and give
response ASAP. If it does not work I try using a second receiver that
handles the boot action and nothing else... hope I can solve the
problem soon ;-)
Thanks for your help!
-DannyS.
On 27 Jan., 15:23, Kostya Vasilyev<[email protected]> wrote:
Danny,
Your app's manifest for the broadcast action, as well as the permission,
look fine.
When you start the emulator, make sure you don't have "Wipe user data"
enabled, as that will erase the application, so it won't be available at
boot.
Other than that, maybe you're just not seeing the logcat message? Try
doing something more visible, like a notification or starting an activity.
-- Kostya
27.01.2011 16:49,DannyS. пишет:
Hi Kostya,
I removed the category, but have still the same issue: boot completed
is never recognized. You said you dont see the other action. I create
the Broadcast- Intent and put it into PendingIntent.getBroadcast(),
without a action in AndroidManifest:
...
alertReceiverIntent = new Intent(this, AlertReceiver.class);
alarmSender = PendingIntent.getBroadcast(this, task.getId(),
alertReceiverIntent, 0);
// insert a new alert
mAlarmManager.set(AlarmManager.RTC_WAKEUP, deliverTime, alarmSender);
...
The receiver is used like expected, onReceive() is called, but never
when the device came up.
I can try using a second receiver if it is ever possible, only for
boot recognization. But this seems not the best way... My receiver
should be able to differ between actions and do several things...
Thanks a lot!
-DannyS.
On 27 Jan., 14:15, Kostya Vasilyev<[email protected]> wrote:
Danny,
You don't need a<category> in the filter to receive BOOT_COMPLETED,
just<action>. In fact, that's probably the cause of your code not
receiving it.
Also I don't see "the other" action in the manifest, for receiving your
own alarms.
-- Kostya
27.01.2011 16:00,DannyS. пишет:
Hi,
I tried to implement a receiver that will be called when the device
booted:
<receiver android:name=".AlertReceiver">
<intent-filter>
<action
android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.HOME"
/>
</intent-filter>
</receiver>
<uses-permission
android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> is already
added in AndroidManifest.xml.
I am using the receiver for recognizing alarms AND want to use the
same for check whether the device has booted. The alarm came up, but I
found no output on log console for recognizing that the device booted
successfully. Here is the code of the receivers onReceive() method:
if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction()))
Log.i("AlertReceiver", "Boot completed :D");
else {
Log.d("AlertReceiver", "Intent action is: " +
intent.getAction());
Toast.makeText(context, "Alarm scheduled",
Toast.LENGTH_SHORT).show();
System.out.println("AlertManager alert succeeded!");
}
I started the emulator without new installation of my app so I
expected the output "Boot completed :D"... What is my fault? Is my
receiver construct in the manifest incorrect?
Hope you can help me,
Thanks a lot!
-DannyS.
On 20 Jan., 10:33, Kostya Vasilyev<[email protected]> wrote:
Danny,
Android already keeps a global registry of pending intents, so keeping a
parallel hash map should not be necessary.
To cancel an alarm, you don't need a reference to the original Java
object, you can just construct a pending intent the same way as you did
when setting the alarm (including the request code).
The hash table can go away with the process, while alarms persist (with
them being inside Android). If you're relying on the map being an
up-to-date representation of your alarms, make sure that it's correctly
reconstructed from scratch - or get rid of it altogether.
-- Kostya
20.01.2011 11:55,DannyS. пишет:
Good Morning!
Wow, you helped me to get it work. I create a PendingIntent with a
unique id and store the intent mapped to their IDs in a HashMap. I
collect all intents with the known id and can the cancel them using
the AlarmManager. I dont know if it is recommended and efficient to
store those intents in a HashMap, but I need the PendingIntent when
I'll cancel the alarm and it worked.
Maybe I have to optimize something, but now I understood how to work
with the AlarmManager AND multiple scheduling tasks.
Thans a lot!
-DannyS.
On 19 Jan., 17:26, Kostya Vasilyev<[email protected]> wrote:
Danny,
The issue with multiple alarms comes up quite often, this is one of
several responses:
http://groups.google.com/group/android-developers/browse_thread/threa...
-- Kostya
19.01.2011 19:09,DannyS. пишет:
Hi,
the AlarmManager is exactly what I need. It works fine, but I don't
figured out yet how to set more than 1 alarm on a AlarmManager.
I am using a BroadcastReceiver to receive that is called if the
scheduling time is reached. First I forgot to add the receiver- Tag in
the AndroidManifest.xml and wondered why the alarm is not fired ^^ But
now it works, but only for the last data I set on the manager.
Hope you can help, meanwhile I go home and do some searches on
Google :D
´Thanks!
-DannyS.
On Jan 19, 10:49 am, "DannyS."<[email protected]> wrote:
Hello Kostya,
WOW, thank you very much, I'll have a look and reply with results and
questions if I have ;-)
-DannyS.
On Jan 19, 9:09 am, Kostya Vasilyev<[email protected]> wrote:
19.01.2011 10:07,DannyS. пишет:
Hi,
I have a service that is running in background. It needs to send
notifications to the user. In my application you can create data with...
read more »
--
Kostya Vasilyev -- WiFi Manager + pretty widget -- http://kmansoft.wordpress.com
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en