Android的通知应用程序 [英] Android Notification App

查看:161
本文介绍了Android的通知应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在对Android应用程序。我必须登录当用户正在安装/下载一个新的第三方应用程序,任何新安装的应用程序名称。我怎样才能得到,如果用户安装新的应用程序的通知。先谢谢了。

I'm currently working on an android application. I have to log any new installed app name whenever the user is installing/downloading a new third party app. How can I get the notification if the user is installing a new app. Thanks in advance.

public class ApplicationBroadcastService extends BroadcastReceiver {
    public void onReceive(Context context, Intent intent) {
        System.out.print("-------");
    }
}

舱单

    <receiver android:name=".applicationlog.ApplicationBroadcastService">
        <intent-filter>
            <action android:name="android.intent.action.PACKAGE_ADDED"  />
            <action android:name="android.intent.action.PACKAGE_CHANGED" />
            <action android:name="android.intent.action.PACKAGE_INSTALL" />
            <action android:name="android.intent.action.PACKAGE_REMOVED" />
            <action android:name="android.intent.action.PACKAGE_REPLACED" />
        </intent-filter>
     </receiver>

但我仍没有进入的onReceive方法,当我安装/卸载任何应用程序。

But still I do not enter the onReceive method, when I am installing/uninstalling any app.

下面是解决方案:

我做我的清单文件一个小的变化。

I did a small change in my Manifest file.

    <intent-filter>
            <category android:name="android.intent.category.DEFAULT" />
            <action android:name="android.intent.action.PACKAGE_ADDED"  />
            <action android:name="android.intent.action.PACKAGE_CHANGED" />
            <action android:name="android.intent.action.PACKAGE_INSTALL" />
            <action android:name="android.intent.action.PACKAGE_REMOVED" />
            <action android:name="android.intent.action.PACKAGE_REPLACED" />
            <data android:scheme="package" />
        </intent-filter>

现在它的正常工作.. :) 再次感谢@willytate

Now it's working fine.. :) Thanks again @willytate

推荐答案

阿贾伊,

您需要设置一个的BroadcastReceiver 与意图过滤器,以收到以下动作:<一href="http://developer.android.com/reference/android/content/Intent.html#ACTION_PACKAGE_ADDED"><$c$c>ACTION_PACKAGE_ADDED然后从的BroadcastReceiver的的onReceive()方法,你可以发动通知

You will need to setup a BroadcastReceiver with an intent filter to receive the following Action: ACTION_PACKAGE_ADDED then from the onReceive() method of the BroadcastReceiver you can launch a Notification.

这篇关于Android的通知应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆