Android Question SMTP and POP3 stop working after approx. 24h

MFfromGermany

Member
Licensed User
Hey guys,

I have the following problem: i created an app that receives mails via POP3 every couple of minutes (as a service) and sends mails via SMTP by button click.

It all works until approx. 24h have passed. Then I have to restart my phone in order to make it work again.

First I declared both SMTP and POP3 as global variables and initialized them when needed, then I tried declaring and initializing them in the subs in which they are needed. Both ways work fine for some time, then the same problem occurs. But there's no exception thrown (I did it with toastmessageshow to realize when some error occurs, but obviously it didn't).

Maybe one of you guys could give me a hint.

Greetings from Germany
 

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

MFfromGermany

Member
Licensed User
That's exactly what I do (service is started every 2 minutes by StartServiceAt). As I said, it stops working after one day, in between that day it works perfectly, it grabs mails and downloads them and sends mails in between these 24h, but afterwards it won't work until I restart my phone.
 
Upvote 0

MFfromGermany

Member
Licensed User
As it seems there do not occur any errors.

Well, I think it's time to explain a little better what I am trying to achieve.
I have a foreground service, which looks for, downloads and saves mails every 2 minutes. This I do with StartServiceAt.

In the main activity there I send mails by clicking on a button.

So you recommend creating another service that stops my mail service and restarts it again let's say every 2 hours. I will try that.

But how to solve the problem corresponding with the activity itself? I mean the app is closed most of the time. Shouldn't that do the same?
 
Upvote 0

An Schi

Well-Known Member
Licensed User
Two noobish questins:

Does the webservice punish you for making to many requests in a certain timeframe?
Does your router disconnect every 24h?
 
Upvote 0

MFfromGermany

Member
Licensed User
Well, now I've tried everything that was suggested in this thread. As it did't work I made everything as it was before I asked this question and now nothing works at all.
 
Upvote 0

MFfromGermany

Member
Licensed User
Well. Now I got it.

For the activity itself it seems that there's no need for calling "ExitApplication" at all, even though there's a foreground service. What I had to do is calling SMTP.Initialize botj in Activity_Create and Activity_Resume. So that works for now.

Fore the foreground service I've created another sticky service that gives the foreground service a hint (let's say it that way) to restart itself before it connects via POP3 the next time (so that I don't stop the service while it might be downloading some mails).

I guess there's a better way to do that, and I'm still thankful for every hint that I get, but for me this way of solving my problem fits.
 
Upvote 0
Top