send message over internet on shutdown intent

  • 2 Antworten
  • Letztes Antwortdatum
G

gummibumm

Neues Mitglied
0
Hey *,

I'm currently developing an activity which should send a message (http get) over the internet (telegram api).
In general this is working really nice!
But now I want to trigger such a message if the device is going for shutdown.
For this I registered a BroadcastReceiver which receives the ACTION_SHUTDOWN Intent.
This also works! But if I want to handle the receive... so if I actually want to send this message... I think my http client crashes or so... Do you have an idea about this?
Maybe the internet connection is not available on shutdown? (Would be bad :/)

Have a nice day!
Marcel
 
I don't know if the internet connection is available at shutdown.
But what you can try is to start an IntentService in your BroadcastReceiver since BroadcastReceivers have an execution time limit which can easily be exceeded when doing network.
 
Hello,

Android-Hilfe.de is a german community and you must write in german.

At least just put your question in the Google Translator and post it additionally to your english request like that:

Hey * ,

Ich entwickle eine Tätigkeit, die eine Nachricht ( HTTP GET ) über das Internet (Telegramm api ) senden sollte .
In der Regel wird dies funktioniert wirklich nett!
Aber jetzt möchte ich eine solche Meldung auslösen , wenn das Gerät wird für das Herunterfahren .
Dafür registrierte ich eine BroadcastReceiver die die ACTION_SHUTDOWN Intent erhält .
Dies funktioniert auch ! Aber wenn ich in der Handhabung der Empfangs ... so , wenn ich tatsächlich , diese Botschaft senden wollen ... Ich denke, meine http Client abstürzt oder so ... Haben Sie eine Idee dazu?
Vielleicht ist die Internet-Verbindung ist nicht auf Herunterfahren zur Verfügung? ( Schlecht wäre : / )

Einen schönen Tag noch!
Marcel


On the other Hand of yourse you can take answers in german and translate it into english again.

This should make a conversation easy.


edit: As of your question I just can say that this is going to be a race between your code and the shutdown of the daemon that are necessary to make such requests. Maybe your request is to slow and Android shuts down the necessary daemon thread for network transmissions, so its a gamble if it will work or not....


Best regards
 
Zurück
Oben Unten