[android-developers] services in android

2012-07-10 Thread Ashu
can we create a service without any activity

i hav an application of email sending automatically so i made a activity 
and run it as a service when my device is switched on after booting it 
start automatically and display the ui of activity,, i dnt want dis 
ui,,what shall i do help me

i want my app should start in background without displaying ui,
how to make it service without any activity
can we make service without any activity..help me

thanks

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] services in android

2012-07-10 Thread Justin Anderson

 can we create a service without any activity

Sounds like some sort of spyware to me... Fortunately, newer versions of
Android have made this impossible.

i hav an application of email sending automatically so i made a activity
 and run it as a service when my device is switched on after booting it
 start automatically and display the ui of activity,, i dnt want dis
 ui,,what shall i do help me

Newer versions of Android prevent your app from doing anything, including
responding to broadcasts (such as to notify that the device has been turned
on) until the user first initiates a launch of your app.

i want my app should start in background without displaying ui,

That is possible, but must be done through an Activity... Use
Theme.NoDisplay on your activity, have it start your service, and then
finish.

how to make it service without any activity
 can we make service without any activity..help me

Do you really need to ask the same question multiple times?  I understood
you the first time.

It sounds to me like you have an incomplete understanding of how services
work on Android... they should not run forever, and Android will kill your
service if it needs the memory...  I would highly recommend checking out
Mark Murphy's article on services:

http://www.androidguys.com/2009/09/09/diamonds-are-forever-services-are-not/

Thanks,
Justin Anderson
MagouyaWare Developer
http://sites.google.com/site/magouyaware


On Sat, Jul 7, 2012 at 1:05 AM, Ashu ashutosh0...@gmail.com wrote:

 can we create a service without any activity


-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] services in android

2012-07-10 Thread Kristopher Micinski
On Tue, Jul 10, 2012 at 11:28 AM, Justin Anderson magouyaw...@gmail.com wrote:
 can we create a service without any activity

 Sounds like some sort of spyware to me... Fortunately, newer versions of
 Android have made this impossible.


I disagree.. We typically use services devoid of UI for implementing
utility like routines.  They don't run forever, and aren't intended
to, but for farming out some shared code to a service that runs in the
background (or, in our case, getting security through more sandboxing
across processes), it works fine.  There is also an activity that can
be started by the user, to check up on things happening in the
service, but it's not a requirement...

kris

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] services in android

2012-07-10 Thread Justin Anderson
He has a service that he wants to run without having any interaction from
the user whatsoever... He wants it to be completely transparent to the
user, meaning they do not know it is running.  That doesn't sound like
spyware?

Thanks,
Justin Anderson
MagouyaWare Developer
http://sites.google.com/site/magouyaware


On Tue, Jul 10, 2012 at 9:34 AM, Kristopher Micinski krismicin...@gmail.com
 wrote:

 On Tue, Jul 10, 2012 at 11:28 AM, Justin Anderson magouyaw...@gmail.com
 wrote:
  can we create a service without any activity
 
  Sounds like some sort of spyware to me... Fortunately, newer versions of
  Android have made this impossible.
 

 I disagree.. We typically use services devoid of UI for implementing
 utility like routines.  They don't run forever, and aren't intended
 to, but for farming out some shared code to a service that runs in the
 background (or, in our case, getting security through more sandboxing
 across processes), it works fine.  There is also an activity that can
 be started by the user, to check up on things happening in the
 service, but it's not a requirement...

 kris

 --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en


-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] services in android

2012-07-10 Thread Kristopher Micinski
On Tue, Jul 10, 2012 at 11:42 AM, Justin Anderson magouyaw...@gmail.com wrote:
 He has a service that he wants to run without having any interaction from
 the user whatsoever... He wants it to be completely transparent to the user,
 meaning they do not know it is running.  That doesn't sound like spyware?


Yes, unless it's attached to a program that user *does* know is
running.  (This is the case for the code I typically write.)

If the user literally doesn't know it's running, at all, then that
sounds bad, if the user doesn't need to notice it's running, then
maybe that's not as bad.. In any case, any attempt to keep an
everlasting service in the background (without a notification in the
foreground) is also bad design and will eventually be killed off by
the system anyway.

So, the OP should specify exactly why he needs it.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] services in android

2012-07-10 Thread Dianne Hackborn
On Tue, Jul 10, 2012 at 8:28 AM, Justin Anderson magouyaw...@gmail.comwrote:

 i want my app should start in background without displaying ui,

 That is possible, but must be done through an Activity... Use
 Theme.NoDisplay on your activity, have it start your service, and then
 finish.


No, that is not running in the background.  That is an activity that
assumes it will never be seen by the user, but it is still at the top of
the stack and if you don't immediately finish it you will give the user
your app in a broken state.

To the original poster -- of course you can use a Service without an
Activity.  There is nothing about a Service that ties it to an Activity,
anywhere in the API.

1. Implement a Service.
2. Declare it in your manifest.
3. call startService() at the point you want it to start.

-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en