Android 防止Service被系统回收

来源:互联网 发布:农村淘宝加盟官方网站 编辑:程序博客网 时间:2024/06/05 10:42
对于Service被系统回收,一般做法是通过提高优先级可以解决,在AndroidManifest.xml文件中对于intent-filter可以通过android:priority = "1000"这个属性设置最高优先级,1000是最高值,如果数字越小则优先级越低,同时实用于广播。

如:
<service 
            android:enabled="true"
            android:name="com.android.trafficman.main.TrafficService">
            <intent-filter android:priority = "1000">
                
            </intent-filter>            
</service>

0 0