List of usage examples for android.content Intent ACTION_PACKAGE_CHANGED
String ACTION_PACKAGE_CHANGED
To view the source code for android.content Intent ACTION_PACKAGE_CHANGED.
Click Source Link
From source file:com.google.android.apps.dashclock.ExtensionPackageChangeReceiver.java
@Override public void onReceive(Context context, Intent intent) { ExtensionManager extensionManager = ExtensionManager.getInstance(context); if (extensionManager.cleanupExtensions()) { LOGD(TAG, "Extension cleanup performed and action taken."); Intent widgetUpdateIntent = new Intent(context, DashClockService.class); widgetUpdateIntent.setAction(DashClockService.ACTION_UPDATE_WIDGETS); startWakefulService(context, widgetUpdateIntent); }//from w w w .jav a 2 s. c o m // If this is a replacement or change in the package, update all active extensions from // this package. String action = intent.getAction(); if (Intent.ACTION_PACKAGE_CHANGED.equals(action) || Intent.ACTION_PACKAGE_REPLACED.equals(action)) { String packageName = intent.getData().getSchemeSpecificPart(); if (TextUtils.isEmpty(packageName)) { return; } Set<ComponentName> activeExtensions = extensionManager.getActiveExtensionNames(); for (ComponentName cn : activeExtensions) { if (packageName.equals(cn.getPackageName())) { LOGD(TAG, "Package for extension " + cn + " changed; asking it for an update."); Intent extensionUpdateIntent = new Intent(context, DashClockService.class); extensionUpdateIntent.setAction(DashClockService.ACTION_UPDATE_EXTENSIONS); // TODO: UPDATE_REASON_PACKAGE_CHANGED extensionUpdateIntent.putExtra(DashClockService.EXTRA_COMPONENT_NAME, cn.flattenToShortString()); startWakefulService(context, extensionUpdateIntent); } } } }
From source file:com.android.settingslib.drawer.SettingsDrawerActivity.java
@Override protected void onResume() { super.onResume(); if (mDrawerLayout != null) { final IntentFilter filter = new IntentFilter(Intent.ACTION_PACKAGE_ADDED); /**//from w w w .j a v a 2 s . c om * xinsi * * Intent.ACTION_PACKAGE_REMOVED: * Broadcast Action: An existing application package has been removed from the device. * * Intent.ACTION_PACKAGE_REPLACED: * Broadcast Action: A new version of an application package has been installed, * replacing an existing version that was previously installed. */ filter.addAction(Intent.ACTION_PACKAGE_REMOVED); filter.addAction(Intent.ACTION_PACKAGE_CHANGED); filter.addAction(Intent.ACTION_PACKAGE_REPLACED); filter.addDataScheme("package"); registerReceiver(mPackageReceiver, filter); new CategoriesUpdater().execute(); } final Intent intent = getIntent(); if (intent != null) { if (intent.hasExtra(EXTRA_SHOW_MENU)) { if (intent.getBooleanExtra(EXTRA_SHOW_MENU, false)) { // Intent explicitly set to show menu. showMenuIcon(); } } else if (isTopLevelTile(intent)) { showMenuIcon(); } } }
From source file:com.example.android.home.Home.java
/** * Registers various intent receivers. The current implementation registers * only a wallpaper intent receiver to let other applications change the * wallpaper.//from w ww . j av a2 s. c o m */ private void registerIntentReceivers() { IntentFilter filter = new IntentFilter(Intent.ACTION_WALLPAPER_CHANGED); registerReceiver(mWallpaperReceiver, filter); filter = new IntentFilter(Intent.ACTION_PACKAGE_ADDED); filter.addAction(Intent.ACTION_PACKAGE_REMOVED); filter.addAction(Intent.ACTION_PACKAGE_CHANGED); filter.addDataScheme("package"); registerReceiver(mApplicationsReceiver, filter); }
From source file:com.anysoftkeyboard.addons.AddOnsFactory.java
private boolean isEventRequiresCacheRefresh(Intent eventIntent) throws NameNotFoundException { String action = eventIntent.getAction(); String packageNameSchemePart = eventIntent.getData().getSchemeSpecificPart(); if (Intent.ACTION_PACKAGE_ADDED.equals(action)) { //will reset only if the new package has my addons boolean hasAddon = isPackageContainAnAddon(packageNameSchemePart); if (hasAddon) { Logger.d(mTag, "It seems that an addon exists in a newly installed package " + packageNameSchemePart + ". I need to reload stuff."); return true; }/* w w w . j a va 2s.c o m*/ } else if (Intent.ACTION_PACKAGE_REPLACED.equals(action) || Intent.ACTION_PACKAGE_CHANGED.equals(action)) { //If I'm managing OR it contains an addon (could be new feature in the package), I want to reset. boolean isPackagedManaged = isPackageManaged(packageNameSchemePart); if (isPackagedManaged) { Logger.d(mTag, "It seems that an addon I use (in package " + packageNameSchemePart + ") has been changed. I need to reload stuff."); return true; } else { boolean hasAddon = isPackageContainAnAddon(packageNameSchemePart); if (hasAddon) { Logger.d(mTag, "It seems that an addon exists in an updated package " + packageNameSchemePart + ". I need to reload stuff."); return true; } } } else //removed { //so only if I manage this package, I want to reset boolean isPackagedManaged = isPackageManaged(packageNameSchemePart); if (isPackagedManaged) { Logger.d(mTag, "It seems that an addon I use (in package " + packageNameSchemePart + ") has been removed. I need to reload stuff."); return true; } } return false; }
From source file:com.google.android.apps.muzei.settings.SettingsChooseSourceFragment.java
@Override public void onResume() { super.onResume(); updateSources();//from w w w. j a va2 s . co m IntentFilter packageChangeIntentFilter = new IntentFilter(); packageChangeIntentFilter.addAction(Intent.ACTION_PACKAGE_ADDED); packageChangeIntentFilter.addAction(Intent.ACTION_PACKAGE_CHANGED); packageChangeIntentFilter.addAction(Intent.ACTION_PACKAGE_REPLACED); packageChangeIntentFilter.addAction(Intent.ACTION_PACKAGE_REMOVED); packageChangeIntentFilter.addDataScheme("package"); getActivity().registerReceiver(mPackagesChangedReceiver, packageChangeIntentFilter); }
From source file:com.mappn.gfan.ui.HomeTabActivity.java
private void registerReceivers() { IntentFilter filter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION); registerReceiver(mNetworkReceiver, filter); IntentFilter intentClickFilter = new IntentFilter(Constants.BROADCAST_CLICK_INTENT); registerReceiver(mIntentClickReceiver, intentClickFilter); IntentFilter appFilter = new IntentFilter(); appFilter.addAction(Intent.ACTION_PACKAGE_ADDED); appFilter.addAction(Intent.ACTION_PACKAGE_REMOVED); appFilter.addAction(Intent.ACTION_PACKAGE_CHANGED); appFilter.addDataScheme("package"); registerReceiver(mInstallReceiver, appFilter); IntentFilter updatefilter = new IntentFilter(); updatefilter.addAction(Constants.BROADCAST_FORCE_EXIT); updatefilter.addAction(Constants.BROADCAST_REMIND_LATTER); updatefilter.addAction(Constants.BROADCAST_DOWNLOAD_OPT); updatefilter.addAction(Constants.BROADCAST_DOWNLOAD); registerReceiver(mUpdateReceiver, updatefilter); }
From source file:com.fastbootmobile.encore.service.PlaybackService.java
/** * Called when the service is created/*from ww w .j a v a2 s. c o m*/ */ @Override public void onCreate() { super.onCreate(); mListenLogger = new ListenLogger(this); mPrefetcher = new Prefetcher(this); mCommandsHandlerThread = new HandlerThread("PlaybackServiceCommandsHandler"); mCommandsHandlerThread.start(); mCommandsHandler = new CommandHandler(this, mCommandsHandlerThread); // Register package manager to receive updates mPacManReceiver = new PacManReceiver(); IntentFilter pacManFilter = new IntentFilter(); pacManFilter.addAction(Intent.ACTION_PACKAGE_ADDED); pacManFilter.addAction(Intent.ACTION_PACKAGE_CHANGED); pacManFilter.addAction(Intent.ACTION_PACKAGE_FULLY_REMOVED); pacManFilter.addAction(Intent.ACTION_PACKAGE_REMOVED); pacManFilter.addAction(Intent.ACTION_PACKAGE_REPLACED); pacManFilter.addDataScheme("package"); registerReceiver(mPacManReceiver, pacManFilter); // Really Google, I'd love to use your new APIs... But they're not working. If you use // the new Lollipop metadata system, you lose Bluetooth AVRCP since the Bluetooth // package still use the old RemoteController system. /*if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { mRemoteMetadata = new RemoteMetadataManagerv21(this); } else*/ { mRemoteMetadata = new RemoteMetadataManager(this); } ProviderAggregator.getDefault().addUpdateCallback(this); // Native playback initialization mNativeHub = new NativeHub(getApplicationContext()); mNativeSink = new NativeAudioSink(); mNativeHub.setSinkPointer(mNativeSink.getPlayer().getHandle()); mNativeHub.setOnAudioWrittenListener(this); mNativeHub.onStart(); mDSPProcessor = new DSPProcessor(this); mDSPProcessor.restoreChain(this); // Plugins initialization PluginsLookup.getDefault().initialize(getApplicationContext()); PluginsLookup.getDefault().registerProviderListener(this); List<ProviderConnection> connections = PluginsLookup.getDefault().getAvailableProviders(); for (ProviderConnection conn : connections) { if (conn.getBinder(false) != null) { assignProviderAudioSocket(conn); } else { Log.w(TAG, "Cannot assign audio socket to " + conn.getIdentifier() + ", binder is null"); } } // Setup mIsStopping = false; // Bind to all provider List<ProviderConnection> providers = PluginsLookup.getDefault().getAvailableProviders(); for (ProviderConnection pc : providers) { try { IMusicProvider binder = pc.getBinder(false); if (binder != null) { binder.registerCallback(mProviderCallback); } } catch (RemoteException e) { Log.e(TAG, "Cannot register callback", e); } } // Register AutoMix manager mCallbacks.add(AutoMixManager.getDefault()); // Setup notification system mNotification = new ServiceNotification(this); mNotification.setOnNotificationChangedListener(new ServiceNotification.NotificationChangedListener() { @Override public void onNotificationChanged(ServiceNotification notification) { NotificationManagerCompat nmc = NotificationManagerCompat.from(PlaybackService.this); if (mIsForeground) { notification.notify(nmc); mIsForeground = true; } else { notification.notify(PlaybackService.this); } BitmapDrawable albumArt = notification.getAlbumArt(); mRemoteMetadata.setAlbumArt(albumArt); } }); // Setup lockscreen remote controls mRemoteMetadata.setup(); // Setup playback wakelock (but don't acquire it yet) PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "OmniMusicPlayback"); // Restore preferences SharedPreferences prefs = getSharedPreferences(SERVICE_SHARED_PREFS, MODE_PRIVATE); mRepeatMode = prefs.getBoolean(PREF_KEY_REPEAT, false); mShuffleMode = prefs.getBoolean(PREF_KEY_SHUFFLE, false); // TODO: Use callbacks // Restore playback queue after one second - we have multiple things to wait here: // - The callbacks of the main app's UI // - The providers connecting // - The providers ready to send us data mHandler.postDelayed(new Runnable() { @Override public void run() { SharedPreferences queuePrefs = getSharedPreferences(QUEUE_SHARED_PREFS, MODE_PRIVATE); mPlaybackQueue.restore(queuePrefs); mCurrentTrack = queuePrefs.getInt("current", -1); mCurrentTrackLoaded = false; mNotification.setHasNext(mPlaybackQueue.size() > 1 || (mPlaybackQueue.size() > 0 && mRepeatMode)); } }, 1000); }
From source file:org.mariotaku.twidere.app.TwidereApplication.java
@Override public void onCreate() { sInstance = this; if (BuildConfig.DEBUG) { StrictModeUtils.detectAllVmPolicy(); }/*www. j a v a 2s . co m*/ final SharedPreferences preferences = getSharedPreferences(); resetTheme(preferences); super.onCreate(); mProfileImageViewViewProcessor = new ProfileImageViewViewProcessor(); mFontFamilyTagProcessor = new FontFamilyTagProcessor(); ATE.registerViewProcessor(TabPagerIndicator.class, new TabPagerIndicatorViewProcessor()); ATE.registerViewProcessor(FloatingActionButton.class, new FloatingActionButtonViewProcessor()); ATE.registerViewProcessor(ActionBarContextView.class, new ActionBarContextViewViewProcessor()); ATE.registerViewProcessor(SwipeRefreshLayout.class, new SwipeRefreshLayoutViewProcessor()); ATE.registerViewProcessor(TimelineContentTextView.class, new TimelineContentTextViewViewProcessor()); ATE.registerViewProcessor(TextView.class, new TextViewViewProcessor()); ATE.registerViewProcessor(ImageView.class, new ImageViewViewProcessor()); ATE.registerViewProcessor(MaterialEditText.class, new MaterialEditTextViewProcessor()); ATE.registerViewProcessor(ProgressWheel.class, new ProgressWheelViewProcessor()); ATE.registerViewProcessor(ProfileImageView.class, mProfileImageViewViewProcessor); ATE.registerTagProcessor(OptimalLinkColorTagProcessor.TAG, new OptimalLinkColorTagProcessor()); ATE.registerTagProcessor(FontFamilyTagProcessor.TAG, mFontFamilyTagProcessor); ATE.registerTagProcessor(IconActionButtonTagProcessor.PREFIX_COLOR, new IconActionButtonTagProcessor(IconActionButtonTagProcessor.PREFIX_COLOR)); ATE.registerTagProcessor(IconActionButtonTagProcessor.PREFIX_COLOR_ACTIVATED, new IconActionButtonTagProcessor(IconActionButtonTagProcessor.PREFIX_COLOR_ACTIVATED)); ATE.registerTagProcessor(IconActionButtonTagProcessor.PREFIX_COLOR_DISABLED, new IconActionButtonTagProcessor(IconActionButtonTagProcessor.PREFIX_COLOR_DISABLED)); ATE.registerTagProcessor(ThemedMultiValueSwitch.PREFIX_TINT, new ThemedMultiValueSwitch.TintTagProcessor()); mProfileImageViewViewProcessor.setStyle(Utils.getProfileImageStyle(preferences)); mFontFamilyTagProcessor.setFontFamily(ThemeUtils.getThemeFontFamily(preferences)); final int themeColor = preferences.getInt(KEY_THEME_COLOR, ContextCompat.getColor(this, R.color.branding_color)); if (!ATE.config(this, VALUE_THEME_NAME_LIGHT).isConfigured()) { //noinspection WrongConstant ATE.config(this, VALUE_THEME_NAME_LIGHT).primaryColor(themeColor) .accentColor(ThemeUtils.getOptimalAccentColor(themeColor, Color.BLACK)).coloredActionBar(true) .coloredStatusBar(true).commit(); } if (!ATE.config(this, VALUE_THEME_NAME_DARK).isConfigured()) { ATE.config(this, VALUE_THEME_NAME_DARK) .accentColor(ThemeUtils.getOptimalAccentColor(themeColor, Color.WHITE)).coloredActionBar(false) .coloredStatusBar(true).statusBarColor(Color.BLACK).commit(); } if (!ATE.config(this, null).isConfigured()) { ATE.config(this, null).accentColor(ThemeUtils.getOptimalAccentColor(themeColor, Color.WHITE)) .coloredActionBar(false).coloredStatusBar(false).commit(); } initializeAsyncTask(); initDebugMode(); initBugReport(); mHandler = new Handler(); final PackageManager pm = getPackageManager(); final ComponentName main = new ComponentName(this, MainActivity.class); final ComponentName main2 = new ComponentName(this, MainHondaJOJOActivity.class); final boolean mainDisabled = pm .getComponentEnabledSetting(main) != PackageManager.COMPONENT_ENABLED_STATE_ENABLED; final boolean main2Disabled = pm .getComponentEnabledSetting(main2) != PackageManager.COMPONENT_ENABLED_STATE_ENABLED; final boolean noEntry = mainDisabled && main2Disabled; if (noEntry) { pm.setComponentEnabledSetting(main, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP); } else if (!mainDisabled) { pm.setComponentEnabledSetting(main2, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); } if (!Utils.isComposeNowSupported(this)) { final ComponentName assist = new ComponentName(this, AssistLauncherActivity.class); pm.setComponentEnabledSetting(assist, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); } migrateUsageStatisticsPreferences(); Utils.startRefreshServiceIfNeeded(this); DependencyHolder holder = DependencyHolder.get(this); registerActivityLifecycleCallbacks(holder.getActivityTracker()); final IntentFilter packageFilter = new IntentFilter(); packageFilter.addAction(Intent.ACTION_PACKAGE_CHANGED); packageFilter.addAction(Intent.ACTION_PACKAGE_ADDED); packageFilter.addAction(Intent.ACTION_PACKAGE_REMOVED); packageFilter.addAction(Intent.ACTION_PACKAGE_REPLACED); registerReceiver(new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { final int uid = intent.getIntExtra(Intent.EXTRA_UID, -1); final String[] packages = getPackageManager().getPackagesForUid(uid); DependencyHolder holder = DependencyHolder.get(context); final ExternalThemeManager manager = holder.getExternalThemeManager(); if (ArrayUtils.contains(packages, manager.getEmojiPackageName())) { manager.reloadEmojiPreferences(); } } }, packageFilter); }
From source file:com.google.android.apps.muzei.settings.ChooseSourceFragment.java
@Override public void onResume() { super.onResume(); updateSources();/*ww w . j a v a 2 s.c o m*/ IntentFilter packageChangeIntentFilter = new IntentFilter(); packageChangeIntentFilter.addAction(Intent.ACTION_PACKAGE_ADDED); packageChangeIntentFilter.addAction(Intent.ACTION_PACKAGE_CHANGED); packageChangeIntentFilter.addAction(Intent.ACTION_PACKAGE_REPLACED); packageChangeIntentFilter.addAction(Intent.ACTION_PACKAGE_REMOVED); packageChangeIntentFilter.addDataScheme("package"); getContext().registerReceiver(mPackagesChangedReceiver, packageChangeIntentFilter); }
From source file:com.mobileglobe.android.customdialer.common.model.AccountTypeManager.java
/** * Internal constructor that only performs initial parsing. *//*from ww w . ja v a2 s.c om*/ public AccountTypeManagerImpl(Context context) { mContext = context; mFallbackAccountType = new FallbackAccountType(context); mAccountManager = AccountManager.get(mContext); mListenerThread = new HandlerThread("AccountChangeListener"); mListenerThread.start(); mListenerHandler = new Handler(mListenerThread.getLooper()) { @Override public void handleMessage(Message msg) { switch (msg.what) { case MESSAGE_LOAD_DATA: loadAccountsInBackground(); break; case MESSAGE_PROCESS_BROADCAST_INTENT: processBroadcastIntent((Intent) msg.obj); break; } } }; mInvitableAccountTypeCache = new InvitableAccountTypeCache(); // Request updates when packages or accounts change IntentFilter filter = new IntentFilter(Intent.ACTION_PACKAGE_ADDED); filter.addAction(Intent.ACTION_PACKAGE_REMOVED); filter.addAction(Intent.ACTION_PACKAGE_CHANGED); filter.addDataScheme("package"); mContext.registerReceiver(mBroadcastReceiver, filter); IntentFilter sdFilter = new IntentFilter(); sdFilter.addAction(Intent.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE); sdFilter.addAction(Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE); mContext.registerReceiver(mBroadcastReceiver, sdFilter); // Request updates when locale is changed so that the order of each field will // be able to be changed on the locale change. filter = new IntentFilter(Intent.ACTION_LOCALE_CHANGED); mContext.registerReceiver(mBroadcastReceiver, filter); if (ActivityCompat.checkSelfPermission(mContext, Manifest.permission.GET_ACCOUNTS) != PackageManager.PERMISSION_GRANTED) { // TODO: Consider calling // ActivityCompat#requestPermissions // here to request the missing permissions, and then overriding // public void onRequestPermissionsResult(int requestCode, String[] permissions, // int[] grantResults) // to handle the case where the user grants the permission. See the documentation // for ActivityCompat#requestPermissions for more details. return; } mAccountManager.addOnAccountsUpdatedListener(this, mListenerHandler, false); ContentResolver.addStatusChangeListener(ContentResolver.SYNC_OBSERVER_TYPE_SETTINGS, this); mListenerHandler.sendEmptyMessage(MESSAGE_LOAD_DATA); }