[android-developers] Re: RssFeed Update

2010-02-03 Thread himanshu jain
@Raghavendra

Here is my code i used wake_lock and release it but it seems not to be
working :-
abstract public class WakefulIntentService extends IntentService {
abstract void doWakefulWork(Intent intent);

public static final String LOCK_NAME_STATIC =
"MyCompany.DdayService.Static";
private static PowerManager.WakeLock lockStatic = null;

public static void acquireStaticLock(Context context) {
getLock(context).acquire();
}

synchronized private static PowerManager.WakeLock getLock(Context
context) {
if (lockStatic == null) {
PowerManager mgr = (PowerManager) context

.getSystemService(Context.POWER_SERVICE);
lockStatic = 
mgr.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
LOCK_NAME_STATIC);
lockStatic.setReferenceCounted(true);
}
return (lockStatic);
}

public WakefulIntentService(String name) {
super(name);
}

@Override
final protected void onHandleIntent(Intent intent) {
doWakefulWork(intent);
getLock(this).release();
}
}

I used alram manger for repeating the process that manager call
onAlarmReceiver which calls my service which had dowakfulwork
function

but after sometimes it throws network unreachable may be due to wifi
network not available, I have a question can we really implement
background service that updates indefinitely even if phone is in sleep
mode .?



thanks

On Feb 3, 2:19 am, raghavendra k  wrote:
> Hi,
>
>     Have you used partial wake lock? I got the similar problem in my
> app. I fixed it by using wake lock. Following is my code snippet. May
> be this will help you.
>
> PowerManager.WakeLock wl;
>                 try {
>                         PowerManager pm = (PowerManager) context
>                                         
> .getSystemService(Context.POWER_SERVICE);
>                         wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, 
> "Nyros");
>                         if (wl != null)
>                                 wl.acquire();
>                         //do your stuff here
>
>                 } catch (Exception ex) {
>
>                 } finally {
>                         if (wl != null)
>                                 wl.release();
>
>                 }
>
> Thanks & Regards,
> Raghavendra K.

-- 
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


[android-developers] Re: RssFeed Update

2010-02-03 Thread raghavendra k
Hi,

Have you used partial wake lock? I got the similar problem in my
app. I fixed it by using wake lock. Following is my code snippet. May
be this will help you.


PowerManager.WakeLock wl;
try {
PowerManager pm = (PowerManager) context

.getSystemService(Context.POWER_SERVICE);
wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, 
"Nyros");
if (wl != null)
wl.acquire();
//do your stuff here

} catch (Exception ex) {

} finally {
if (wl != null)
wl.release();

}

Thanks & Regards,
Raghavendra K.

-- 
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