How can I get Actions: PACKAGE_REMOVED and PACKAGE_ADDED

Showing 1-9 of 9 messages
How can I get Actions: PACKAGE_REMOVED and PACKAGE_ADDED Joe 1/21/08 7:25 PM
I want to get the Installing and removing package name, I found that
there are two
broadcast Actions: PACKAGE_REMOVED and PACKAGE_ADDED can help doing
that.
And I found the permission about packages is only
"android.permission.BROADCAST_PACKAGE_REMOVED"
and "android.permission.INSTALL_PACKAGES", but they are not associated
with the two actions.
So I cannot process these two actions.
Following is my test code, can anyone tell me what's wrong with my
codes or how can I get the actions.
.....
    <uses-permission
id="android.permission.BROADCAST_PACKAGE_REMOVED" />
    <uses-permission id="android.permission.INSTALL_PACKAGES" />
....
        <receiver class=".PackageProcess">
            <intent-filter>
                <action
android:value="android.provider.Telephony.SMS_RECEIVED" />
                <action
android:value="android.intent.action.PACKAGE_ADDED"         />
                <action
android:value="android.intent.action.PACKAGE_REMOVED" />
            </intent-filter>
        </receiver>
....
     public void onReceiveIntent(Context context, Intent intent) {
          /* As we want to display a Notification, we the
NotificationManager */

          Log.i("recevie the message is ", intent.getAction());  //can
not print this line
......
}
Re: How can I get Actions: PACKAGE_REMOVED and PACKAGE_ADDED hackbod 1/23/08 1:56 PM
To receive these actions, you need to handle the "package:" scheme.
The Intent being broadcast sends the package name as
"package:<name>".  So you should write something like this:

            <intent-filter>
                <action
android:value="android.intent.action.PACKAGE_ADDED" />
                <action
android:value="android.intent.action.PACKAGE_REMOVED" />
                <scheme android:value="package" />
            </intent-filter>

The two permissions you mentioned are not relevant -- the
BROADCAST_PACKAGE_REMOVED permission is to allow you to -broadcast-
that intent (which you aren't needing to do), and INSTALL_PACKAGES is
to allow you to physically install a package on the device.
Re: How can I get Actions: PACKAGE_REMOVED and PACKAGE_ADDED Joe 1/23/08 5:44 PM
Thanks, that works.
Re: How can I get Actions: PACKAGE_REMOVED and PACKAGE_ADDED jcku...@gmail.com 2/21/08 11:56 PM
Hello,

Can we create a package with service and use that service in
application when package is installed ? do you know how can we create
package for service.

Thanks
Jitendra

On Jan 24, 2:56 am, hackbod <hack...@gmail.com> wrote:
> To receive these actions, you need to handle the "package:" scheme.
> The Intent being broadcast sends the package name as
> "package:<name>".  So you should write something like this:
>
>             <intent-filter>
>                 <action
> android:value="android.intent.action.PACKAGE_ADDED" />
>                 <action
> android:value="android.intent.action.PACKAGE_REMOVED" />
>                 <scheme android:value="package" />
>             </intent-filter>
>
> The two permissions you mentioned are not relevant -- the
> BROADCAST_PACKAGE_REMOVED permission is to allow you to -broadcast-
> that intent (which you aren't needing to do), and INSTALL_PACKAGES is
> to allow you to physically install a package on the device.
>
> On Jan 21, 7:25 pm, Joe <pencil...@hotmail.com> wrote:
>
> > I want to get theInstallingand removing package name, I found that
> > there are two
> > broadcast Actions: PACKAGE_REMOVED and PACKAGE_ADDED can help doing
> > that.
> > And I found the permission aboutpackagesis only
Re: How can I get Actions: PACKAGE_REMOVED and PACKAGE_ADDED hackbod 2/22/08 12:05 AM
Um, I have no idea what you are asking. :)  The discussion here is
about .apk files, containing an entire application (unfortunately the
name "android package" is confusing with Java packages).
Re: How can I get Actions: PACKAGE_REMOVED and PACKAGE_ADDED jcku...@gmail.com 2/22/08 2:04 AM
do you have any idea about how to create apk files using aapt tool.
can you give me one example for creating apk package ?
Re: How can I get Actions: PACKAGE_REMOVED and PACKAGE_ADDED viktor 2/27/08 3:43 PM
What event(s) in the system triggers the PACKAGE_ADDED intent? Is
running the command "adb install mypackage.apk" sufficient? I tried it
and my registered intent receiver does not receive the intent. So I
need to know if my manifest is wrong or the intent does not get
broadcasted.

Also, is the intent broadcasted to the package that has just been
installed?

Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.obd2.test">
    <application android:icon="@drawable/icon">
        <activity android:name="Test" android:label="@string/
app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category
android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
    <receiver android:name="PackageAddedReceiver">
        <intent-filter>
             <action
android:name="android.intent.action.PACKAGE_ADDED" />
        </intent-filter>
    </receiver>
</manifest>

Receiver:
public class PackageAddedReceiver extends IntentReceiver {
        @Override
        public void onReceiveIntent(Context conext, Intent intent) {
                android.util.Log.i("test", intent.getData().toString());
> > }- Hide quoted text -
>
> - Show quoted text -
Re: How can I get Actions: PACKAGE_REMOVED and PACKAGE_ADDED hackbod 2/27/08 3:52 PM
Yes, PACKAGE_ADDED is broadcast.  You need to also say you handle the
"package" scheme (the data is a Uri of the form "package:<package-
name>").

The broadcast will probably be sent to the package that got installed,
but uh...  nice that you mention that, I might change that. ;)

Fwiw, this is the code in the home screen that registers a receiver at
runtime:

        filter = new IntentFilter(Intent.PACKAGE_ADDED_ACTION);
        filter.addAction(Intent.PACKAGE_REMOVED_ACTION);
        filter.addAction(Intent.PACKAGE_CHANGED_ACTION);
        filter.addDataScheme("package");
        registerReceiver(mApplicationsReceiver, filter);
Re: How can I get Actions: PACKAGE_REMOVED and PACKAGE_ADDED viktor 2/27/08 5:13 PM
Thank you, now it works.

> The broadcast will probably be sent to the package that got installed,
> but uh...  nice that you mention that, I might change that. ;)

Please do not change that! This is a useful feature. Imagine an
application that requires a service constantly running. For example an
application that monitors phone location and notifies the user when he
approaches certain geographical point. The application uses the
BOOT_COMPLETED broadcast to start the service when the phone boots up.
The application also must start the service when the new version is
installed because deleting the apk file kills the service. To do so,
the application will listen for PACKAGE_INSTALL, PACKAGE_ADDED and
PACKAGE_CHANGED broadcasts and start the service if the intent data
matches the application package name. If you prevent these broadcasts
to the package that got installed, please provide an application with
a mechanism to run some code after it gets installed on the phone.

Just to make this topic complete, here is the manifest that worked for
me:

        <receiver android:name="PackageAddedReceiver">
        <intent-filter>
              <action android:name="android.intent.action.PACKAGE_INSTALL" />
                <action android:name="android.intent.action.PACKAGE_ADDED" />
                <action android:name="android.intent.action.PACKAGE_CHANGED" /
>
                <category android:name="android.intent.category.DEFAULT" />
                <data android:scheme="package" />
        </intent-filter>
        </receiver>
> > > - Show quoted text -- Hide quoted text -