在已禁用的服务上调用startService()

时间:2015-04-30 13:02:52

标签: android android-service

我有一次我想要使用的服务,只有一次。

我第一次启动服务后,通过以下方式禁用它:

Uint8Array.prototype.getBitSum=function() {
 var _t=0;
 [].forEach.call(this, function(v, i) { _t+=Math.pow(256,i)*v; });
 return _t;
}

Uint8Array.prototype.getBit=function(b) {
 var _t=this.getBitSum();
 return ((_t & Math.pow(2,b)) != false);
}

Uint8Array.prototype.setBit=function(b, v) {
 var _v=v;
 if (isNaN(_v)) return false;
 var _B=Math.floor(b/8), _B_b=(b%8);
 if (_v) this[_B]|=Math.pow(2,_B_b);
 else this[_B]&=(255-Math.pow(2,_B_b));
 return true;
}

再次调用ComponentName componentName = new ComponentName(context, MyService.class); PackageManager pm = context.getPackageManager(); pm.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); 将无效(按预期)。

我的问题是:以这种方式做我想做的事情有问题吗?我能想到的唯一选择是使用保存在SharedPreferences中的标志。

0 个答案:

没有答案
相关问题