List of usage examples for android.content Intent ACTION_PACKAGE_ADDED
String ACTION_PACKAGE_ADDED
To view the source code for android.content Intent ACTION_PACKAGE_ADDED.
Click Source Link
From source file:com.amaze.filemanager.fragments.AppsList.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setHasOptionsMenu(false);//from www.j ava 2 s .c o m ic = new IconHolder(getActivity(), true, true); IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(Intent.ACTION_PACKAGE_ADDED); intentFilter.addAction(Intent.ACTION_PACKAGE_REMOVED); intentFilter.addDataScheme("package"); getActivity().registerReceiver(br, intentFilter); }
From source file:org.wso2.iot.agent.events.listeners.ApplicationStateListener.java
@Override public void onReceive(Context context, final Intent intent) { String status = null;//from ww w .j av a2 s . com ApplicationStatus applicationState; this.context = context; switch (intent.getAction()) { case Intent.ACTION_PACKAGE_ADDED: status = "added"; applyEnforcement(intent.getData().getEncodedSchemeSpecificPart()); break; case Intent.ACTION_PACKAGE_REMOVED: status = "removed"; break; case Intent.ACTION_PACKAGE_REPLACED: status = "upgraded"; break; case Intent.ACTION_PACKAGE_DATA_CLEARED: status = "dataCleared"; break; default: Log.i(TAG, "Invalid intent received"); } if (status != null) { String packageName = intent.getData().getEncodedSchemeSpecificPart(); applicationState = new ApplicationStatus(); applicationState.setState(status); applicationState.setPackageName(packageName); try { String appState = CommonUtils.toJSON(applicationState); publishEvent(appState, Constants.EventListeners.APPLICATION_STATE); if (Constants.DEBUG_MODE_ENABLED) { Log.d(TAG, appState); } } catch (AndroidAgentException e) { Log.e(TAG, "Could not convert to JSON"); } if (Intent.ACTION_PACKAGE_REPLACED.equals(intent.getAction()) && Constants.AGENT_PACKAGE.equals(packageName)) { Intent broadcastIntent = new Intent(); broadcastIntent.setAction(Constants.AGENT_UPDATED_BROADCAST_ACTION); context.sendBroadcast(broadcastIntent); } } }
From source file:net.digitalfeed.pdroidalternative.intenthandler.PackageChangeHandler.java
@Override public void onReceive(Context context, Intent intent) { Log.d("PDroidAlternative", "PackageChangeHandler event received"); //Get the package name. If this fails, then the intent didn't contain the //essential data and should be ignored String packageName;//from www . j a v a 2s . c o m Uri inputUri = Uri.parse(intent.getDataString()); if (!inputUri.getScheme().equals("package")) { Log.d("PDroidAlternative", "Intent scheme was not 'package'"); return; } packageName = inputUri.getSchemeSpecificPart(); //If a package is being removed, we only want to delete the related //info it is not being updated/replaced by a newer version if (intent.getAction().equals(Intent.ACTION_PACKAGE_REMOVED)) { if (!intent.getBooleanExtra(Intent.EXTRA_REPLACING, false)) { Log.d("PDroidAlternative", "Triggering application deletion for package:" + packageName); DBInterface.getInstance(context).deleteApplicationRecord(packageName); } } else if (intent.getAction().equals(Intent.ACTION_PACKAGE_ADDED)) { //If the package is just getting updated, then we only need to notify the user //if the permissions have changed if (intent.getBooleanExtra(Intent.EXTRA_REPLACING, false)) { //TODO: check if the permissions have changed Log.d("PDroidAlternative", "PackageChangeHandler: App being replaced: " + packageName); Application oldApp = Application.fromDatabase(context, packageName); Application newApp = Application.fromPackageName(context, packageName); if (havePermissionsChanged(context, oldApp, newApp)) { //TODO: Handle permission change /* * This is an app for which the permissions have been updated, * so we need to update the database to include only correct permissions. * Maybe we should have some way of flagging new ones? */ newApp.setStatusFlags( (newApp.getStatusFlags() | oldApp.getStatusFlags() | Application.STATUS_FLAG_UPDATED) & ~Application.STATUS_FLAG_NEW); DBInterface.getInstance(context).updateApplicationRecord(newApp); displayNotification(context, NotificationType.update, packageName, DBInterface.getInstance(context).getApplicationLabel(packageName)); } } else { /* * This is a new app, not an app being replaced. We need to add it to the * database, then display a notification for it */ Log.d("PDroidAlternative", "PackageChangeHandler: New app added: " + packageName); /* * I'm not sure if we really want to be doing all this processing here, but * we do need to record a list of new/updated apps to write to the database * when the app next starts, or the intent is executed - or we do it now */ //get the application from the system, not from the database Application app = Application.fromPackageName(context, packageName); app.setStatusFlags(app.getStatusFlags() | Application.STATUS_FLAG_NEW); DBInterface.getInstance(context).addApplicationRecord(app); Log.d("PDroidAlternative", "PackageChangeHandler: New app record added: " + packageName); displayNotification(context, NotificationType.newinstall, packageName, app.getLabel()); Log.d("PDroidAlternative", "PackageChangeHandler: Notification presented: " + packageName); } } }
From source file:com.lullabot.android.apps.iosched.ui.SessionDetailFragment.java
@Override public void onResume() { super.onResume(); // Start listening for time updates to adjust "now" bar. TIME_TICK is // triggered once per minute, which is how we move the bar over time. final IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_PACKAGE_ADDED); filter.addAction(Intent.ACTION_PACKAGE_REMOVED); filter.addAction(Intent.ACTION_PACKAGE_REPLACED); filter.addDataScheme("package"); getActivity().registerReceiver(mPackageChangesReceiver, filter); }
From source file:tw.idv.gasolin.pycontw2012.ui.SessionDetailFragment.java
@Override public void onResume() { super.onResume(); // Start listening for time updates to adjust "now" bar. TIME_TICK is // triggered once per minute, which is how we move the bar over time. final IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_PACKAGE_ADDED); filter.addAction(Intent.ACTION_PACKAGE_REMOVED); filter.addAction(Intent.ACTION_PACKAGE_REPLACED); filter.addDataScheme("package"); }
From source file:com.nbplus.vbroadlauncher.ShowApplicationActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); overridePendingTransition(R.anim.fade_in, R.anim.fade_out); setContentView(R.layout.activity_show_application); IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_PACKAGE_ADDED); filter.addAction(Intent.ACTION_PACKAGE_REMOVED); filter.addDataScheme("package"); showProgressDialog();//from w ww .j a va 2s. co m registerReceiver(mPackageInstallReceiver, filter); mLoadAsyncTask = new InstalledApplicationTask(this, mHandler); mLoadAsyncTask.execute(); // ViewPager . // ??? ? ? ? . mViewPager = (NbplusViewPager) findViewById(R.id.viewPager); mIndicator = (LinePageIndicator) findViewById(R.id.indicator); mAppPagerAdapter = new AppPagerAdapter(this, getSupportFragmentManager()); mViewPager.setAdapter(mAppPagerAdapter); mViewPager.setSwipeable(true); mIndicator.setViewPager(mViewPager); mIndicator.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } @Override public void onPageSelected(int position) { Log.d(TAG, ">> page selected position = " + position); } @Override public void onPageScrollStateChanged(int state) { } }); }
From source file:com.goliathonline.android.kegbot.ui.DrinkDetailFragment.java
@Override public void onResume() { super.onResume(); updateNotesTab();/* w w w.j av a2 s. com*/ // Start listening for time updates to adjust "now" bar. TIME_TICK is // triggered once per minute, which is how we move the bar over time. final IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_PACKAGE_ADDED); filter.addAction(Intent.ACTION_PACKAGE_REMOVED); filter.addAction(Intent.ACTION_PACKAGE_REPLACED); filter.addDataScheme("package"); getActivity().registerReceiver(mPackageChangesReceiver, filter); }
From source file:com.google.android.apps.iosched2.ui.SessionDetailFragment.java
@Override public void onResume() { super.onResume(); SetupHelper.loadCurrentSetup(getActivity()); updateNotesTab();// ww w .ja v a2 s. co m // Start listening for time updates to adjust "now" bar. TIME_TICK is // triggered once per minute, which is how we move the bar over time. final IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_PACKAGE_ADDED); filter.addAction(Intent.ACTION_PACKAGE_REMOVED); filter.addAction(Intent.ACTION_PACKAGE_REPLACED); filter.addDataScheme("package"); getActivity().registerReceiver(mPackageChangesReceiver, filter); }
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 . java2s .c o m*/ * 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.linkbubble.MainService.java
@Override public void onCreate() { mDestroyAllActivities = true;/* w ww . j a va 2s. co m*/ mRestoreComplete = false; setTheme(Settings.get().getDarkThemeEnabled() ? R.style.MainServiceThemeDark : R.style.MainServiceThemeLight); super.onCreate(); Fabric.with(this, new Crashlytics()); CrashTracking.log("MainService.onCreate()"); showDefaultNotification(); Config.init(this); Settings.get().onOrientationChange(); try { WebIconDatabase.getInstance().open(getDir("icons", MODE_PRIVATE).getPath()); } catch (RuntimeException exc) { CrashTracking.logHandledException(exc); } MainApplication.mDestroyActivitySharedLock = new Object(); MainApplication.mActivityDestroyed = false; MainController.create(this, new MainController.EventHandler() { @Override public void onDestroy() { Settings.get().saveBubbleRestingPoint(); stopSelf(); CrashTracking.log("MainService.onCreate(): onDestroy()"); } }); //Intent i = new Intent(); //i.setData(Uri.parse("https://t.co/uxMl3bWtMP")); //i.setData(Uri.parse("http://t.co/oOyu7GBZMU")); //i.setData(Uri.parse("http://goo.gl/abc57")); //i.setData(Uri.parse("https://bitly.com/QtQET")); //i.setData(Uri.parse("http://www.duckduckgo.com")); //openUrl("https://www.duckduckgo.com"); //openUrl("http://www.duckduckgo.com", true); //openUrl("https://t.co/uxMl3bWtMP", true); IntentFilter filter = new IntentFilter(); filter.addAction(BCAST_CONFIGCHANGED); registerReceiver(mBroadcastReceiver, filter); registerReceiver(mDialogReceiver, new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)); filter = new IntentFilter(Intent.ACTION_PACKAGE_ADDED); filter.addAction(Intent.ACTION_PACKAGE_REMOVED); filter.addDataScheme("package"); filter = new IntentFilter(Intent.ACTION_SCREEN_ON); filter.addAction(Intent.ACTION_SCREEN_OFF); filter.addAction(Intent.ACTION_USER_PRESENT); registerReceiver(mScreenReceiver, filter); MainApplication.registerForBus(this, this); }