Thank you so much! it works

在 2008年2月28日星期四 UTC+8上午7:52:10,hackbod写道:
>
> 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); 
>
> On Feb 27, 3:43 pm, viktor <[email protected]> wrote: 
> > 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()); 
> >         } 
> > 
> > } 
> > 
> > On Jan 23, 4:56 pm, hackbod <[email protected]> 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 <[email protected]> wrote: 
> > 
> > > > 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 
> > > > ...... 
> > 
> > > > }- Hide quoted text - 
> > 
> > > - Show quoted text -

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/e4bcd6bd-0520-41b9-ba81-e4c607f24cd5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to