我通过蓝牙从arduino板接收一些数据..这个数据接收和数据存储到文本文件是在一个名为BackgroundService的类中完成的,它是扩展服务类..
所以现在我想断开关于我的Android应用程序的Forcefull关闭的数据,我怎么能这样做,我尝试使用onStop(),stopService()方法,但它不起作用..
stopService方法
@Override
public boolean stopService(Intent name) {
// TODO Auto-generated method stub
Amarino.disconnect(getApplicationContext(), DEVICE_ADDRESS);
unregisterReceiver(arduinoReceiver);
return super.stopService(name);
}
答案 0 :(得分:1)
您可以使用API 14
中添加的onTrimMemory()
public abstract void onTrimMemory (int level)
Called when the operating system has determined that it is a good time for a process
to trim unneeded memory from its process. This will happen for example when it goes
in the background and there is not enough memory to keep as many background
processes running as desired.
检查link。 Ver良好的链接,解释了应用程序如何工作以及如何在低内存中关闭它们。