List of usage examples for android.content ComponentName ComponentName
private ComponentName(String pkg, Parcel in)
From source file:barqsoft.footballscores.widget.WidgetListProvider.java
@Override public void onReceive(@NonNull Context context, @NonNull Intent intent) { super.onReceive(context, intent); if (ScoresSyncAdapter.ACTION_DATA_UPDATED.equals(intent.getAction())) { AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context); int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(context, getClass())); //This method will trigger WidgetListRemoteViewsService RemoteViewsFactory // .onDataChanged() and update the widget UI appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetIds, R.id.widget_list); }/* w w w .j av a 2 s . c o m*/ }
From source file:atv.com.project.monkeylivetv.Activity.MainActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { // menu.clear(); getMenuInflater().inflate(R.menu.main_menu, menu); //Share/*from w w w . j a v a 2 s.c om*/ MenuItem menuItem = menu.findItem(R.id.action_share); shareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(menuItem); setShareIntent(createShareIntent()); //Search MenuItem searchItem = menu.findItem(R.id.action_search); SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem); searchView.setOnQueryTextListener(this); SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); searchView.setSearchableInfo( searchManager.getSearchableInfo(new ComponentName(this, SearchableActivity.class))); searchView.setIconifiedByDefault(false); return true; }
From source file:cn.studyjams.s2.sj0119.NForget.AlarmReceiver.java
public void setAlarm(Context context, Calendar calendar, int ID) { mAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); // Put Reminder ID in Intent Extra Intent intent = new Intent(context, AlarmReceiver.class); intent.putExtra(ReminderEditActivity.EXTRA_REMINDER_ID, Integer.toString(ID)); mPendingIntent = PendingIntent.getBroadcast(context, ID, intent, PendingIntent.FLAG_CANCEL_CURRENT); // Calculate notification time Calendar c = Calendar.getInstance(); long currentTime = c.getTimeInMillis(); long diffTime = calendar.getTimeInMillis() - currentTime; // Start alarm using notification time mAlarmManager.set(AlarmManager.ELAPSED_REALTIME, SystemClock.elapsedRealtime() + diffTime, mPendingIntent); // Restart alarm if device is rebooted ComponentName receiver = new ComponentName(context, BootReceiver.class); PackageManager pm = context.getPackageManager(); pm.setComponentEnabledSetting(receiver, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP); }
From source file:com.bayapps.android.robophish.ui.BaseActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); LogHelper.d(TAG, "Activity onCreate"); if (Build.VERSION.SDK_INT >= 21) { // Since our app icon has the same color as colorPrimary, our entry in the Recent Apps // list gets weird. We need to change either the icon or the color // of the TaskDescription. ActivityManager.TaskDescription taskDesc = new ActivityManager.TaskDescription(getTitle().toString(), BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher_white), ResourceHelper.getThemeColor(this, R.attr.colorPrimary, android.R.color.darker_gray)); setTaskDescription(taskDesc);/* www . j a va2 s . c o m*/ } // Connect a media browser just to get the media session token. There are other ways // this can be done, for example by sharing the session token directly. mMediaBrowser = new MediaBrowserCompat(this, new ComponentName(this, MusicService.class), mConnectionCallback, null); mRegistrationBroadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { //mRegistrationProgressBar.setVisibility(ProgressBar.GONE); SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); boolean sentToken = sharedPreferences.getBoolean(QuickstartPreferences.SENT_TOKEN_TO_SERVER, false); if (sentToken) { //mInformationTextView.setText(getString(R.string.gcm_send_message)); } else { //mInformationTextView.setText(getString(R.string.token_error_message)); } } }; // Registering BroadcastReceiver registerReceiver(); if (checkPlayServices()) { // Start IntentService to register this application with GCM. Intent intent = new Intent(this, RegistrationIntentService.class); startService(intent); } }
From source file:com.androidzeitgeist.dashwatch.muzei.SourceManager.java
public List<SourceListing> getAvailableSources() { List<SourceListing> sources = new ArrayList<SourceListing>(); PackageManager pm = mApplicationContext.getPackageManager(); List<ResolveInfo> resolveInfos = pm.queryIntentServices(new Intent(MuzeiArtSource.ACTION_MUZEI_ART_SOURCE), PackageManager.GET_META_DATA); for (ResolveInfo resolveInfo : resolveInfos) { SourceListing listing = new SourceListing(); listing.componentName = new ComponentName(resolveInfo.serviceInfo.packageName, resolveInfo.serviceInfo.name); listing.title = resolveInfo.loadLabel(pm).toString(); sources.add(listing);/*from ww w. j a va 2s .c o m*/ } return sources; }
From source file:com.johan.vertretungsplan.background.VertretungsplanService.java
@Override protected void onHandleIntent(Intent intent) { context = this; settings = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); extras = intent.getExtras();/*from w w w .ja v a 2 s . c om*/ Gson gson = new Gson(); boolean autoSync; try { autoSync = extras.getBoolean("AutoSync"); } catch (NullPointerException e) { autoSync = false; } ConnectivityManager conMan = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); //wifi State wifi = conMan.getNetworkInfo(1).getState(); if (wifi == NetworkInfo.State.CONNECTED || autoSync == false || settings.getBoolean("syncWifi", false) == false) { Log.d("Vertretungsplan", "WiFi state: " + wifi); Log.d("Vertretungsplan", "autoSync: " + autoSync); Log.d("Vertretungsplan", "syncWifi: " + Boolean.valueOf(settings.getBoolean("syncWifi", false))); Log.d("Vertretungsplan", "Vertretungsplan wird abgerufen"); try { BaseParser parser = ((VertretungsplanApplication) getApplication()).getParser(); if (parser == null) return; Vertretungsplan v = parser.getVertretungsplan(); settings.edit().putString("Vertretungsplan", gson.toJson(v)).commit(); AppWidgetManager mgr = AppWidgetManager.getInstance(this); int[] ids = mgr.getAppWidgetIds(new ComponentName(this, VertretungsplanWidgetProvider.class)); new VertretungsplanWidgetProvider().onUpdate(this, mgr, ids); } catch (IOException | JSONException e) { e.printStackTrace(); } catch (VersionException e) { } catch (UnauthorizedException e) { } } }
From source file:com.appsaur.tarucassist.AutomuteAlarmReceiver.java
public void setAlarm(Context context, Calendar calendar, int ID) { mAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); // Put Reminder ID in Intent Extra Intent intent = new Intent(context, AutomuteAlarmReceiver.class); intent.putExtra(BaseActivity.EXTRA_REMINDER_ID, Integer.toString(ID)); mPendingIntent = PendingIntent.getBroadcast(context, ID, intent, PendingIntent.FLAG_CANCEL_CURRENT); // Calculate notification time Calendar c = Calendar.getInstance(); long currentTime = c.getTimeInMillis(); long diffTime = calendar.getTimeInMillis() - currentTime; // Start alarm using notification time mAlarmManager.set(AlarmManager.ELAPSED_REALTIME, SystemClock.elapsedRealtime() + diffTime, mPendingIntent); // Restart alarm if device is rebooted ComponentName receiver = new ComponentName(context, BootReceiver.class); PackageManager pm = context.getPackageManager(); pm.setComponentEnabledSetting(receiver, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP); }
From source file:com.jieehd.villain.toolkit.stats.ReportingService.java
private void promptUser() { NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); Intent nI = new Intent(); nI.setComponent(new ComponentName(getPackageName(), AnonymousStats.class.getName())); PendingIntent pI = PendingIntent.getActivity(this, 0, nI, 0); Notification.Builder builder = new Notification.Builder(this).setAutoCancel(true) .setTicker("Annonymous Statistics").setContentIntent(pI).setWhen(0) .setContentTitle("Annonymous Statistics").setContentText("Enable Reporting"); nm.notify(1, builder.getNotification()); }
From source file:com.example.samsungmdm.MainActivity.java
private void grantAdminPrivileges() { mDPM = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE); mAdminName = new ComponentName(this, MyDeviceAdminReceiver.class); if (!mDPM.isAdminActive(mAdminName)) { //Not yet device admin Intent intent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN); intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, mAdminName); intent.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION, "This needs to be added"); startActivityForResult(intent, REQUEST_ENABLE); }/*from w w w. jav a2s . co m*/ }
From source file:androidx.navigation.NavDeepLinkBuilder.java
/** * Sets an explicit Activity to be started by the deep link created by this class. * * @param activityClass The Activity to start. This Activity should have a {@link NavController} * which uses the same {@link NavGraph} used to construct this * deep link./* ww w .j a v a2s . c o m*/ * @return this object for chaining */ @NonNull public NavDeepLinkBuilder setComponentName(@NonNull Class<? extends Activity> activityClass) { return setComponentName(new ComponentName(mContext, activityClass)); }