×

Discussion Board

Results 1 to 9 of 9
  1. #1
    Registered User
    Join Date
    Jul 2012
    Posts
    20

    Periodic task in windows phone

    Hi all, i have one question related to periodic task in windows phone,

    Is periodic agent gets launched after every 30 minutes by just installing the application??, means i never launched my application i just installed it, and my application contains code for registering the periodic task (i.e ScheduledActionService.Add(periodicTask)).

    I want this because i want to check in background agent that whether user had launched application from last n days.

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,697

    Re: Periodic task in windows phone

    Quote Originally Posted by mehul_raje View Post
    Is periodic agent gets launched after every 30 minutes by just installing the application??
    No.
    means i never launched my application i just installed it, and my application contains code for registering the periodic task (i.e ScheduledActionService.Add(periodicTask)).
    If you have not launched it, how that code line would execute?
    I want this because i want to check in background agent that whether user had launched application from last n days.
    Remember that background agents are not bulletproof. User can disable them on some devices at least, on some other devices they are not supported at all. Also, the general registration cap is 2 weeks, though there are some exceptions.

  3. #3
    Nokia Developer Champion
    Join Date
    Sep 2012
    Location
    Morocco
    Posts
    296

    Re: Periodic task in windows phone

    Quote Originally Posted by mehul_raje View Post
    I want this because i want to check in background agent that whether user had launched application from last n days.
    Hello,
    can you be more specific about this line ? there may be some workarrounds for it.

  4. #4
    Registered User
    Join Date
    Jul 2012
    Posts
    20

    Re: Periodic task in windows phone

    I have following requirement,

    If user had installed my application but he never launched it for say 5 days then i wants to show him toast notification(from background agent), after doing some rnd i came to know that background agent gets up even though the application never launched but now my problem is how do i calculate 5 days difference because i don't have any way to find the date at which application was installed.

  5. #5
    Nokia Developer Champion
    Join Date
    Mar 2013
    Posts
    511

    Re: Periodic task in windows phone

    If you run your agent the first time you save the current date to IsolatedStorage. On every consecutive run you compare the saved date with the current date and when the 5 days are reached you pop up your message. I don't believe that having a BackgroundAgent for that task is a good idea (especially as the amount of BackgroundAgents on a user's device is limited).

  6. #6
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,697

    Re: Periodic task in windows phone

    Quote Originally Posted by mehul_raje View Post
    background agent gets up even though the application never launched but now my problem is how do i calculate 5 days difference because i don't have any way to find the date at which application was installed.
    Assuming that background agents schedule automatically, installation happened approximately 30 (10) minutes before the first schedule ever. So you can store a related file in your isolated storage. If it does not exist, create it and store current time. If it exists, compare it to current time. When 5 days passed, raise the toast.

  7. #7
    Registered User
    Join Date
    Jul 2012
    Posts
    20

    Re: Periodic task in windows phone

    Thanks guys for your help,

    finally i made it as per your suggestions.

  8. #8
    Nokia Developer Champion
    Join Date
    Sep 2012
    Location
    Morocco
    Posts
    296

    Re: Periodic task in windows phone

    Quote Originally Posted by mehul_raje View Post
    after doing some rnd i came to know that background agent gets up even though the application never launched
    Hello, could you please tell us where did you find this ?
    as far as I know a background agent needs to be registered through "code" and this code needs to be executed, so in order for you background agent to be executed, the app must be launched.

  9. #9
    Registered User
    Join Date
    Jul 2012
    Posts
    20

    Re: Periodic task in windows phone

    Quote Originally Posted by Loukt View Post
    Hello, could you please tell us where did you find this ?
    as far as I know a background agent needs to be registered through "code" and this code needs to be executed, so in order for you background agent to be executed, the app must be launched.
    Hi Loukt,
    I just did trial and error for that, first i just installed the application and written some logs in background agent and waited for ~30 mins and then i observed logs which clearly proved that background agent was executed. I think this may be due to the entry of background agent in wmappmanifest file because after the installation agents gets listed in phone's Settings --> applications --> background tasks from where user can enable and disable it.

Similar Threads

  1. Replies: 2
    Last Post: 2013-04-15, 12:10
  2. Windows phone 8 app installation on phone without putting it on windows store
    By KnowledgeSeeker in forum Windows Phone General
    Replies: 2
    Last Post: 2013-03-05, 12:12
  3. Replies: 3
    Last Post: 2010-06-29, 10:34
  4. Periodic Image capture with Nokia 6131 phone
    By amarsahu in forum Streaming and Video
    Replies: 1
    Last Post: 2009-06-05, 14:37
  5. SYNC WITH TASK TIMER FOR WINDOWS
    By eiglauer in forum Symbian Networking & Messaging (Closed)
    Replies: 0
    Last Post: 2002-05-20, 20:57

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×