Re: [android-developers] AlarmManager vs BroadcastReceiver vs Service

2016-06-07 Thread TreKing
On Mon, Jun 6, 2016 at 1:25 PM, Neilz  wrote:

> To the other point, is there actually a way to lauch an app without a main
> activity?


Under normal operation? Sure, in response to system broadcast, for example.
For testing purposes? Sure, using adb shell am

-
TreKing  - Chicago
transit tracking app for Android-powered devices

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/CANCScgiRFStVhSVQhEsvwfJH34cWc%3DqAKdxsi39ZT7X%2BRadBYQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [android-developers] AlarmManager vs BroadcastReceiver vs Service

2016-06-06 Thread Neilz
Thanks TreKing - I get it, the Alarm Receiver is kind of a redundant step 
if all it does is start the Service. But it's not 'wrong' as such.

To the other point, is there actually a way to lauch an app without a main 
activity? I had read it wasn't possible, and when I tried to do so from 
AndroidStudio I just got errors, and didn't look at it any further. Is 
there an example anywhere that you know of?

On Monday, 6 June 2016 06:53:28 UTC+1, TreKing wrote:
>
>
> On Sat, Jun 4, 2016 at 5:50 AM, Neilz  
> wrote:
>
>> Hi. I need a background task to run every minute.
>>
>
>
> https://developers.google.com/android/reference/com/google/android/gms/gcm/GcmNetworkManager
>  
>
>> I have no need for a user interface, although I understand that I must 
>> still declare a launcher activity
>>
>
> No, you don't.
>  
>
>> I'm confused between the use of AlarmManager, Receivers and Services. So 
>> far, I've scheduled a repeating alarm, which passes a class called 
>> AlarmReceiver in its Intent. AlarmReceiver extends BroadcastReceiver, and 
>> the onReceive() method successfully fires every minute, even if I kill the 
>> activity, which is exactly what I want.
>>
>> However, at no point am I using a class which extends Service or 
>> IntentService, which when I look around at other people's examples, seems 
>> to be what everyone does when they want a task to run as a background 
>> service. Am I doing something wrong? Should I be calling a Service class 
>> from my BroadcastReceiver instead of doing the work there?
>>
>
> Probably. You don't really need a receiver in this case. The point of a 
> receiver is to get notified of specific events happening either in you app 
> or throughout the system. If all you're interested in is doing some work 
> every 1 minute, then you don't need the receiver. The alarm manager's 
> intent that is fired when the alarm goes off can just be an intent to 
> launch an a(n) (Intent)Service that does that work.
>
>
> -
> TreKing  - Chicago 
> transit tracking app for Android-powered devices
>

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/5b46c17e-b996-493f-968a-f97017068f31%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [android-developers] AlarmManager vs BroadcastReceiver vs Service

2016-06-05 Thread TreKing
On Sat, Jun 4, 2016 at 5:50 AM, Neilz  wrote:

> Hi. I need a background task to run every minute.
>

https://developers.google.com/android/reference/com/google/android/gms/gcm/GcmNetworkManager


> I have no need for a user interface, although I understand that I must
> still declare a launcher activity
>

No, you don't.


> I'm confused between the use of AlarmManager, Receivers and Services. So
> far, I've scheduled a repeating alarm, which passes a class called
> AlarmReceiver in its Intent. AlarmReceiver extends BroadcastReceiver, and
> the onReceive() method successfully fires every minute, even if I kill the
> activity, which is exactly what I want.
>
> However, at no point am I using a class which extends Service or
> IntentService, which when I look around at other people's examples, seems
> to be what everyone does when they want a task to run as a background
> service. Am I doing something wrong? Should I be calling a Service class
> from my BroadcastReceiver instead of doing the work there?
>

Probably. You don't really need a receiver in this case. The point of a
receiver is to get notified of specific events happening either in you app
or throughout the system. If all you're interested in is doing some work
every 1 minute, then you don't need the receiver. The alarm manager's
intent that is fired when the alarm goes off can just be an intent to
launch an a(n) (Intent)Service that does that work.

-
TreKing  - Chicago
transit tracking app for Android-powered devices

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/CANCScgiOHsZaFRmbDOF28c5sMLTWxWTwou65LmwZrLjoOgjTjQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.