广播接收器的Package

编程入门 行业动态 更新时间:2024-10-25 08:27:28
本文介绍了广播接收器的Package_Install不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

@覆盖公共无效的onReceive(上下文的背景下,意图意图){    // TODO自动生成方法存根    Toast.makeText(背景下,包接,Toast.LENGTH_SHORT).show();    Log.d(包安装,包安装);    字符串行动= intent.getAction();    如果(action.equals(intent.ACTION_PACKAGE_INSTALL))    {        Toast.makeText(背景下,包增加,Toast.LENGTH_SHORT).show();        Log.d(包安装,包安装);    }}

//我的清单文件:

<接收机器人:名字=com.example.anotherbroadcastreceiverexample.MyReceiver机器人:启用=真正的>            <意向滤光器><作用机器人:名字=android.intent.action.PACKAGE_INSTALL/>< /意向滤光器>    < /接收器>

解决方案

你能不能尝试修改你的表现在以下方式:

<意向滤光器>    <作用机器人:名字=android.intent.action.PACKAGE_INSTALL/>    <作用机器人:名字=android.intent.action.PACKAGE_ADDED/>    <数据机器人:计划=包/>&所述; /意图滤光器>

更新:

检查不检查PACKAGE_INSTALL行动PACKAGE_ADDED。

@Override public void onReceive(Context context, Intent intent) { // TODO Auto-generated method stub Toast.makeText(context, "Package Received", Toast.LENGTH_SHORT).show(); Log.d("Package Installing", "Package Installing"); String action=intent.getAction(); if(action.equals(intent.ACTION_PACKAGE_INSTALL)) { Toast.makeText(context, "Package Added", Toast.LENGTH_SHORT).show(); Log.d("Package INstalling", "Package Installed"); } }

//My Manifest File:

<receiver android:name="com.example.anotherbroadcastreceiverexample.MyReceiver" android:enabled="true"> <intent-filter><action android:name="android.intent.action.PACKAGE_INSTALL"/></intent-filter> </receiver>

解决方案

Could you try to modify your Manifest in the following way:

<intent-filter> <action android:name="android.intent.action.PACKAGE_INSTALL" /> <action android:name="android.intent.action.PACKAGE_ADDED" /> <data android:scheme="package"/> </intent-filter>

UPDATE:

Check not PACKAGE_INSTALL check action PACKAGE_ADDED.

更多推荐

广播接收器的Package

本文发布于:2023-11-27 12:58:02,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1638178.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:接收器   Package

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!