avoid of send null from destroyed activity to restarted service

  • Replies:0
  • OpenNot stickiedUnanswered
  • Forum posts: 1

Oct 1, 2017 5:34:28 PM via Website

I want to programing app for data track in background , so I use service .
I want to write a program that monitors all data sent and received by the device, and when the total volume of received or received messages reaches a specified value, the Internet device is turned off.

So I used the following code to monitor the data:
 

mStartRX = TrafficStats.getTotalRxBytes ();
mStartTX = TrafficStats.getTotalTxBytes ();

And I used the services to work on the background in the background.

To specify the download or upload limit from the user with edittext, I requested this limit in mainactivity and send this value to the service.

The problem is when: When I destroy the program, I will restart the service and get the NULL value and the program crashes.

please help me ...