List of usage examples for android.content ComponentName ComponentName
private ComponentName(String pkg, Parcel in)
From source file:com.android.mms.widget.MmsWidgetProvider.java
@Override public void onReceive(Context context, Intent intent) { if (Log.isLoggable(LogTag.WIDGET, Log.VERBOSE)) { Log.v(TAG, "onReceive intent: " + intent); }/*from w w w.java 2s . c om*/ String action = intent.getAction(); // The base class AppWidgetProvider's onReceive handles the normal widget intents. Here // we're looking for an intent sent by the messaging app when it knows a message has // been sent or received (or a conversation has been read) and is telling the widget it // needs to update. if (ACTION_NOTIFY_DATASET_CHANGED.equals(action)) { AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context); int[] appWidgetIds = appWidgetManager .getAppWidgetIds(new ComponentName(context, MmsWidgetProvider.class)); // We need to update all Mms appwidgets on the home screen. appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetIds, R.id.conversation_list); } else { super.onReceive(context, intent); } }
From source file:com.android.tv.receiver.BootCompletedReceiver.java
@Override public void onReceive(Context context, Intent intent) { if (DEBUG)/*from ww w. ja v a 2 s. c o m*/ Log.d(TAG, "boot completed " + intent); // Start {@link NotificationService}. Intent notificationIntent = new Intent(context, NotificationService.class); notificationIntent.setAction(NotificationService.ACTION_SHOW_RECOMMENDATION); context.startService(notificationIntent); // Grant permission to already set up packages after the system has finished booting. SetupUtils.grantEpgPermissionToSetUpPackages(context); if (Features.UNHIDE.isEnabled(context)) { if (OnboardingUtils.isFirstBoot(context)) { // Enable the application if this is the first "unhide" feature is enabled just in // case when the app has been disabled before. PackageManager pm = context.getPackageManager(); ComponentName name = new ComponentName(context, TvActivity.class); if (pm.getComponentEnabledSetting(name) != PackageManager.COMPONENT_ENABLED_STATE_ENABLED) { pm.setComponentEnabledSetting(name, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, 0); } OnboardingUtils.setFirstBootCompleted(context); } } if (CommonFeatures.DVR.isEnabled(context) && BuildCompat.isAtLeastN()) { DvrRecordingService.startService(context); } }
From source file:com.doctoror.surprise.SurpriseActivity.java
@Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); mFragmentTransactionsAllowed = true; setContentView(R.layout.activity_surprise); mLocalBroadcastManager = LocalBroadcastManager.getInstance(this); mLocalBroadcastManager.registerReceiver(mServiceReceiver, mServiceReceiver.mIntentFilter); mAnimatorSurprise = (ViewAnimator) findViewById(R.id.animator_surprise); mAnimatorUpgrade = (ViewAnimator) findViewById(R.id.animator_upgrade); mPackageManager = getPackageManager(); mReceiverComponent = new ComponentName(this, SurpriseReceiver.class); final CompoundButton surprise = (CompoundButton) findViewById(R.id.btn_surprise); surprise.setChecked(mPackageManager/*from ww w.j ava2s .com*/ .getComponentEnabledSetting(mReceiverComponent) == PackageManager.COMPONENT_ENABLED_STATE_ENABLED); surprise.setOnCheckedChangeListener(this); findViewById(R.id.btn_surprise_to_su).setOnClickListener(this); findViewById(R.id.info_surprise).setOnClickListener(this); findViewById(R.id.info_upgrade).setOnClickListener(this); }
From source file:com.hybris.mobile.lib.commerce.provider.CatalogProvider.java
@Override public boolean onCreate() { authority = getContext().getString(R.string.sync_default_authority); String dbName = getContext().getString(R.string.sync_default_db_name); int dbVersion = getContext().getResources().getInteger(R.integer.sync_default_db_version); try {//from w w w . ja v a2s. co m ComponentName componentName = new ComponentName(getContext(), this.getClass()); // Authority name from the manifest file String tmpAuthority = getContext().getPackageManager().getProviderInfo(componentName, PackageManager.GET_META_DATA).authority; if (StringUtils.isNotBlank(tmpAuthority)) { authority = tmpAuthority; } // Database configuration from manifest file Bundle bundle = getContext().getPackageManager().getProviderInfo(componentName, PackageManager.GET_META_DATA).metaData; if (bundle != null) { String dbNameTmp = bundle.getString(getContext().getString(R.string.sync_db_name)); int dbVersionTmp = bundle.getInt(getContext().getString(R.string.sync_db_version)); if (StringUtils.isNotBlank(dbNameTmp)) { dbName = dbNameTmp; } if (dbVersion != 0) { dbVersion = dbVersionTmp; } } // Account name and type componentName = new ComponentName(getContext(), CatalogAuthenticatorService.class); bundle = getContext().getPackageManager().getServiceInfo(componentName, PackageManager.GET_META_DATA).metaData; String accountName = bundle.getString(getContext().getString(R.string.sync_account_name)); String accountType = bundle.getString(getContext().getString(R.string.sync_account_type)); if (StringUtils.isBlank(accountName) || StringUtils.isBlank(accountType)) { throw new IllegalArgumentException( "You must provide the metadata " + getContext().getString(R.string.sync_account_name) + ", " + getContext().getString(R.string.sync_account_type) + " for " + this.getClass()); } account = new Account(accountType, accountName); } catch (PackageManager.NameNotFoundException e) { Log.e(TAG, "Package name not found. Details:" + e.getLocalizedMessage()); throw new IllegalArgumentException( "Error getting the information from the metadata of " + this.getClass()); } // Unit test case - the mock context does not have any package manager or provider info catch (UnsupportedOperationException e) { Log.e(TAG, "Unsupported operation:" + e.getLocalizedMessage()); } mDatabaseHelper = new CatalogDatabaseHelper(getContext(), dbName, dbVersion); URI_MATCHER = new UriMatcher(UriMatcher.NO_MATCH); URI_MATCHER.addURI(authority, CatalogContract.Provider.SEGMENT_GROUP, CatalogContract.Provider.CODE_GROUP); URI_MATCHER.addURI(authority, CatalogContract.Provider.SEGMENT_GROUP + "/*", CatalogContract.Provider.CODE_GROUP_ID); URI_MATCHER.addURI(authority, CatalogContract.Provider.SEGMENT_DATA, CatalogContract.Provider.CODE_DATA); URI_MATCHER.addURI(authority, CatalogContract.Provider.SEGMENT_DATA + "/*", CatalogContract.Provider.CODE_DATA_ID); URI_MATCHER.addURI(authority, CatalogContract.Provider.SEGMENT_DATA_DETAILS, CatalogContract.Provider.CODE_DATA_DETAILS); URI_MATCHER.addURI(authority, CatalogContract.Provider.SEGMENT_DATA_DETAILS + "/*", CatalogContract.Provider.CODE_DATA_DETAILS_ID); URI_MATCHER.addURI(authority, CatalogContract.Provider.SEGMENT_SYNC_GROUP + "/*", CatalogContract.Provider.CODE_SYNC_GROUP); return true; }
From source file:com.battlelancer.seriesguide.appwidget.ListWidgetProvider.java
@Override public void onReceive(Context context, Intent intent) { super.onReceive(context, intent); // check if we received our update alarm if (UPDATE.equals(intent.getAction())) { // trigger refresh of list widgets AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context); int[] appWidgetIds = appWidgetManager .getAppWidgetIds(new ComponentName(context, ListWidgetProvider.class)); appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetIds, R.id.list_view); }//from ww w . ja v a2 s .com }
From source file:com.mono.applink.Foursquare.java
/** Called when the activity is first created. */ @Override/*from w w w . ja v a 2 s .co m*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final String url = getIntent().getData().toString(); if (url.contains("user"))//user with id { new FoursquareUser().execute(); } else if (url.contains("venue")) { new FoursquareVenue().execute(); } else { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage("Sorry, but this type of link is not currently supported"); builder.setOnCancelListener(new OnCancelListener() { public void onCancel(DialogInterface dialog) { finish(); } }); builder.setPositiveButton("Open in Browser", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Intent i = new Intent(); i.setAction("android.intent.action.VIEW"); i.addCategory("android.intent.category.BROWSABLE"); i.setComponent(new ComponentName("com.android.browser", "com.android.browser.BrowserActivity")); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); i.setData(Uri.parse(url)); startActivity(i); finish(); } }); AlertDialog alert = builder.create(); alert.show(); } }
From source file:com.commonsware.android.advservice.callbackbinding.client.DownloadFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setRetainInstance(true);//from www . j av a 2 s.c o m appContext = (Application) getActivity().getApplicationContext(); Intent implicit = new Intent(IDownload.class.getName()); List<ResolveInfo> matches = getActivity().getPackageManager().queryIntentServices(implicit, 0); if (matches.size() == 0) { Toast.makeText(getActivity(), "Cannot find a matching service!", Toast.LENGTH_LONG).show(); } else if (matches.size() > 1) { Toast.makeText(getActivity(), "Found multiple matching services!", Toast.LENGTH_LONG).show(); } else { Intent explicit = new Intent(implicit); ServiceInfo svcInfo = matches.get(0).serviceInfo; ComponentName cn = new ComponentName(svcInfo.applicationInfo.packageName, svcInfo.name); explicit.setComponent(cn); appContext.bindService(explicit, this, Context.BIND_AUTO_CREATE); } }
From source file:com.devbrackets.android.playlistcore.helper.MediaControlsHelper.java
/** * Creates a new MediaControlsHelper object * * @param context The context to use for holding a MediaSession and sending action intents * @param mediaServiceClass The class for the service that owns the backing MediaService and to notify of playback actions *//* w w w . j a va 2 s .com*/ public MediaControlsHelper(@NonNull Context context, @NonNull Class<? extends Service> mediaServiceClass) { this.context = context; ComponentName componentName = new ComponentName(context, MediaControlsReceiver.class.getName()); mediaSession = new MediaSessionCompat(context, SESSION_TAG, componentName, getMediaButtonReceiverPendingIntent(componentName, mediaServiceClass)); mediaSession.setFlags( MediaSessionCompat.FLAG_HANDLES_MEDIA_BUTTONS | MediaSessionCompat.FLAG_HANDLES_TRANSPORT_CONTROLS); mediaSession.setCallback(new SessionCallback(mediaServiceClass)); }
From source file:br.com.imovelhunter.imovelhunterwebmobile.GcmBroadcastReceiver.java
@Override public void onReceive(Context context, Intent intent) { // Explicitly specify that GcmIntentService will handle the intent. ComponentName comp = new ComponentName(context.getPackageName(), GcmIntentService.class.getName()); if (SessionUtilJson.getInstance(context).containsName(ParametrosSessaoJson.USUARIO_LOGADO)) { usuarioLogado = (Usuario) SessionUtilJson.getInstance(context) .getJsonObject(ParametrosSessaoJson.USUARIO_LOGADO, Usuario.class); }/*from w ww. j av a 2s . c om*/ if (mensagemDAO == null) { mensagemDAO = new MensagemDAO(context); } if (notificacaoDAO == null) { notificacaoDAO = new NotificacaoDAO(context); } if (escutadorDeMensagem != null) { Bundle bundle = intent.getExtras(); String mensagemS = bundle.getString("mensagem"); if (!mensagemS.contains("idImovel")) { // uma mensagem do chat Mensagem m = new Mensagem(); m.parse(mensagemS); m.setLida(false); if (usuarioLogado != null && m.getUsuariosDestino().get(0).getIdUsuario() == usuarioLogado.getIdUsuario()) { escutadorDeMensagem.recebeuAlgo(bundle); } else { mensagemDAO.inserirMensagem(m); } } else { // um perfil de imvel Notificacao not = new Notificacao(); Imovel imovel = new Imovel(); imovel.parse(mensagemS); this.parseNotificacao(not, imovel); not.setDataNotificacao(new Date()); notificacaoDAO.inserir(not); if (usuarioLogado != null && usuarioLogado.getIdUsuario() == imovel.getIdUsuarioNotificacao()) { if (onRecebeuNotificacao != null) { onRecebeuNotificacao.recebeuNotificacao(); } else { // Start the service, keeping the device awake while it is launching. startWakefulService(context, (intent.setComponent(comp))); } } } } else { String mensagem = intent.getExtras().getString("mensagem"); boolean notificar = true; if (!mensagem.contains("idImovel")) { // mensagem de chat Mensagem mensagemO = new Mensagem(); mensagemO.parse(mensagem); mensagemO.setLida(false); mensagemDAO.inserirMensagem(mensagemO); if (onMessageListener != null && usuarioLogado != null && usuarioLogado.getIdUsuario() == mensagemO.getUsuariosDestino().get(0).getIdUsuario()) { onMessageListener.atualizar(); } if (usuarioLogado == null || mensagemO.getUsuariosDestino().get(0).getIdUsuario() != usuarioLogado.getIdUsuario()) { notificar = false; } } else { // imvel Notificacao not = new Notificacao(); Imovel imovel = new Imovel(); imovel.parse(mensagem); this.parseNotificacao(not, imovel); not.setDataNotificacao(new Date()); notificacaoDAO.inserir(not); if (usuarioLogado != null && usuarioLogado.getIdUsuario() == imovel.getIdUsuarioNotificacao()) { if (onRecebeuNotificacao != null) { notificar = false; onRecebeuNotificacao.recebeuNotificacao(); } } else { notificar = false; } } if (notificar) { // Start the service, keeping the device awake while it is launching. startWakefulService(context, (intent.setComponent(comp))); } } setResultCode(Activity.RESULT_OK); }
From source file:com.euphor.paperpad.GcmBroadcastReceiver.java
@Override public void onReceive(Context context, Intent intent) { //get GCM registration id if failed to do it directly try {//from w w w . j av a 2s . c o m String regId = intent.getExtras().getString("registration_id"); if (regId != null && !regId.equals("")) { sendRegistrationIdToBackend(context, regId); } } catch (Exception e) { // TODO: handle exception } // Explicitly specify that GcmIntentService will handle the intent. ComponentName comp = new ComponentName(context.getPackageName(), GcmIntentService.class.getName()); // Start the service, keeping the device awake while it is launching. startWakefulService(context, (intent.setComponent(comp))); setResultCode(Activity.RESULT_OK); }