为什么我的软件包取代了Android操作被内容方案忽略了
我在清单中有一个广播的意图过滤器声明为什么我的软件包取代了Android操作被内容方案忽略了,android,broadcast,intentfilter,Android,Broadcast,Intentfilter,我在清单中有一个广播的意图过滤器声明 <intent-filter> <action android:name="android.intent.action.TIME_SET"/> <action android:name="android.intent.action.BOOT_COMPLETED"/> <action android:name="android.int
<intent-filter>
<action android:name="android.intent.action.TIME_SET"/>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<action android:name="android.intent.action.MY_PACKAGE_REPLACED"/>
<data android:scheme="content"/>
</intent-filter>
问题是当我删除
时,会收到我的\u包\u被替换的操作,否则不会
在这种情况下,数据标签是什么?无法从文档中真正理解。
元素表示“在意图上必须有Uri
,并且它必须与
元素中提供的规则相匹配”。在您的特定情况下,规则是“必须存在Uri
,并且必须具有内容
方案”
由于这三个广播都没有使用内容
Uri
,请删除
元素。对于我的包
,您只需使用以下内容:
<receiver
android:name=".UpgradeReceiver" android:enabled="true" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MY_PACKAGE_REPLACED"/>
</intent-filter>
</receiver>
public class UpgradeReceiver extends BroadcastReceiver {
@Override
public void onReceive(final Context context, Intent intent) {
if (!Intent.ACTION_MY_PACKAGE_REPLACED.equals(intent.getAction()))
return;
...
}
}
. 我注意到,如果启用它,它并不总是被接收…它在调试模式下运行,即UpgradeReceiver onReceive调用。但在发布版apk中,它不起作用。有什么建议吗?@girubai应该有用。如果不是,可能是因为即时运行,或者是因为用户选择了“强制停止”或类似的方式。例如,使用log.e(“某物”)写入日志。我现在已经测试过了。工作正常,除非您从未启动过该应用程序。发布版本是proguard,请在proguard文件中保留BoradCasterReceiver的名称,这应该是解决“未在产品中运行”问题的第一个检查。。