Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Notification App

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.

Java File

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

Manifest

    <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>

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

Here is the solution:

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>

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

like image 970
Ajay Singh Avatar asked Mar 31 '11 11:03

Ajay Singh


People also ask

Is there a notification app for Android?

Material Notifications Shade is one of the best notification apps for Android that assists you with important features. You can control notifications for every single app and even choose a custom color, ringtone, vibration pattern and behaviour for each app in your device.


2 Answers

Ajay,

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.

like image 87
Will Tate Avatar answered Sep 28 '22 04:09

Will Tate


Take a look at the intent documentation. You are looking for ACTION_PACKAGE_INSTALL (which seems to be never used, see comments) and ACTION_PACKAGE_REMOVED.

like image 29
WarrenFaith Avatar answered Sep 28 '22 05:09

WarrenFaith