List of usage examples for android.content Intent getLongArrayExtra
public long[] getLongArrayExtra(String name)
From source file:com.android.my.calendar.alerts.DismissAlarmsService.java
@Override public void onHandleIntent(Intent intent) { if (AlertService.DEBUG) { Log.d(TAG, "onReceive: a=" + intent.getAction() + " " + intent.toString()); }//from w ww. j a v a 2s . c om long eventId = intent.getLongExtra(AlertUtils.EVENT_ID_KEY, -1); long eventStart = intent.getLongExtra(AlertUtils.EVENT_START_KEY, -1); long eventEnd = intent.getLongExtra(AlertUtils.EVENT_END_KEY, -1); long[] eventIds = intent.getLongArrayExtra(AlertUtils.EVENT_IDS_KEY); long[] eventStarts = intent.getLongArrayExtra(AlertUtils.EVENT_STARTS_KEY); int notificationId = intent.getIntExtra(AlertUtils.NOTIFICATION_ID_KEY, -1); List<AlarmId> alarmIds = new LinkedList<AlarmId>(); Uri uri = CalendarAlerts.CONTENT_URI; String selection; // Dismiss a specific fired alarm if id is present, otherwise, dismiss all alarms if (eventId != -1) { alarmIds.add(new AlarmId(eventId, eventStart)); selection = CalendarAlerts.STATE + "=" + CalendarAlerts.STATE_FIRED + " AND " + CalendarAlerts.EVENT_ID + "=" + eventId; } else if (eventIds != null && eventIds.length > 0 && eventStarts != null && eventIds.length == eventStarts.length) { selection = buildMultipleEventsQuery(eventIds); for (int i = 0; i < eventIds.length; i++) { alarmIds.add(new AlarmId(eventIds[i], eventStarts[i])); } } else { // NOTE: I don't believe that this ever happens. selection = CalendarAlerts.STATE + "=" + CalendarAlerts.STATE_FIRED; } GlobalDismissManager.dismissGlobally(getApplicationContext(), alarmIds); ContentResolver resolver = getContentResolver(); ContentValues values = new ContentValues(); values.put(PROJECTION[COLUMN_INDEX_STATE], CalendarAlerts.STATE_DISMISSED); resolver.update(uri, values, selection, null); // Remove from notification bar. if (notificationId != -1) { NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); nm.cancel(notificationId); } if (SHOW_ACTION.equals(intent.getAction())) { // Show event on Calendar app by building an intent and task stack to start // EventInfoActivity with AllInOneActivity as the parent activity rooted to home. Intent i = AlertUtils.buildEventViewIntent(this, eventId, eventStart, eventEnd); TaskStackBuilder.create(this).addParentStack(EventInfoActivity.class).addNextIntent(i) .startActivities(); } }
From source file:com.mobicage.rogerthat.SendMessageButtonActivity.java
@Override protected void onServiceBound() { setContentView(R.layout.send_message_button); setActivityName("send_message_button"); setTitle(R.string.title_buttons);//from w w w . j a va 2 s . c o m Intent intent = getIntent(); try { mCannedButtons = (CannedButtons) Pickler .createObjectFromPickle(intent.getByteArrayExtra(CANNED_BUTTONS)); mButtons = new LinkedHashSet<Long>(); long[] buttons = intent.getLongArrayExtra(BUTTONS); if (buttons != null) { for (long l : buttons) { mButtons.add(l); } } } catch (Exception e) { L.bug(e); setResult(Activity.RESULT_CANCELED); finish(); } FloatingActionButton floatingActionButton = (FloatingActionButton) findViewById(R.id.add); floatingActionButton.setImageDrawable( new IconicsDrawable(this, FontAwesome.Icon.faw_plus).color(Color.WHITE).sizeDp(24)); floatingActionButton.setOnClickListener(new SafeViewOnClickListener() { @Override public void safeOnClick(View v) { addButton(); } }); initButtonsList(); }
From source file:com.farmerbb.taskbar.receiver.ReceiveSettingsReceiver.java
@Override public void onReceive(Context context, Intent intent) { // Ignore this broadcast if this is the free version if (BuildConfig.APPLICATION_ID.equals(BuildConfig.PAID_APPLICATION_ID)) { // Get pinned and blocked apps PinnedBlockedApps pba = PinnedBlockedApps.getInstance(context); pba.clear(context);/*ww w . java 2 s.c o m*/ String[] pinnedAppsPackageNames = intent.getStringArrayExtra("pinned_apps_package_names"); String[] pinnedAppsComponentNames = intent.getStringArrayExtra("pinned_apps_component_names"); String[] pinnedAppsLabels = intent.getStringArrayExtra("pinned_apps_labels"); long[] pinnedAppsUserIds = intent.getLongArrayExtra("pinned_apps_user_ids"); UserManager userManager = (UserManager) context.getSystemService(Context.USER_SERVICE); LauncherApps launcherApps = (LauncherApps) context.getSystemService(Context.LAUNCHER_APPS_SERVICE); if (pinnedAppsPackageNames != null && pinnedAppsComponentNames != null && pinnedAppsLabels != null) for (int i = 0; i < pinnedAppsPackageNames.length; i++) { Intent throwaway = new Intent(); throwaway.setComponent(ComponentName.unflattenFromString(pinnedAppsComponentNames[i])); long userId; if (pinnedAppsUserIds != null) userId = pinnedAppsUserIds[i]; else userId = userManager.getSerialNumberForUser(Process.myUserHandle()); AppEntry newEntry = new AppEntry(pinnedAppsPackageNames[i], pinnedAppsComponentNames[i], pinnedAppsLabels[i], IconCache.getInstance(context).getIcon(context, context.getPackageManager(), launcherApps.resolveActivity(throwaway, userManager.getUserForSerialNumber(userId))), true); newEntry.setUserId(userId); pba.addPinnedApp(context, newEntry); } String[] blockedAppsPackageNames = intent.getStringArrayExtra("blocked_apps_package_names"); String[] blockedAppsComponentNames = intent.getStringArrayExtra("blocked_apps_component_names"); String[] blockedAppsLabels = intent.getStringArrayExtra("blocked_apps_labels"); if (blockedAppsPackageNames != null && blockedAppsComponentNames != null && blockedAppsLabels != null) for (int i = 0; i < blockedAppsPackageNames.length; i++) { pba.addBlockedApp(context, new AppEntry(blockedAppsPackageNames[i], blockedAppsComponentNames[i], blockedAppsLabels[i], null, false)); } // Get blacklist Blacklist blacklist = Blacklist.getInstance(context); blacklist.clear(context); String[] blacklistPackageNames = intent.getStringArrayExtra("blacklist_package_names"); String[] blacklistLabels = intent.getStringArrayExtra("blacklist_labels"); if (blacklistPackageNames != null && blacklistLabels != null) for (int i = 0; i < blacklistPackageNames.length; i++) { blacklist.addBlockedApp(context, new BlacklistEntry(blacklistPackageNames[i], blacklistLabels[i])); } // Get top apps TopApps topApps = TopApps.getInstance(context); topApps.clear(context); String[] topAppsPackageNames = intent.getStringArrayExtra("top_apps_package_names"); String[] topAppsLabels = intent.getStringArrayExtra("top_apps_labels"); if (topAppsPackageNames != null && topAppsLabels != null) for (int i = 0; i < topAppsPackageNames.length; i++) { topApps.addTopApp(context, new BlacklistEntry(topAppsPackageNames[i], topAppsLabels[i])); } // Get saved window sizes if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { SavedWindowSizes savedWindowSizes = SavedWindowSizes.getInstance(context); savedWindowSizes.clear(context); String[] savedWindowSizesComponentNames = intent .getStringArrayExtra("saved_window_sizes_component_names"); String[] savedWindowSizesWindowSizes = intent .getStringArrayExtra("saved_window_sizes_window_sizes"); if (savedWindowSizesComponentNames != null && savedWindowSizesWindowSizes != null) for (int i = 0; i < savedWindowSizesComponentNames.length; i++) { savedWindowSizes.setWindowSize(context, savedWindowSizesComponentNames[i], savedWindowSizesWindowSizes[i]); } } // Get shared preferences String contents = intent.getStringExtra("preferences"); if (contents.length() > 0) try { File file = new File(context.getFilesDir().getParent() + "/shared_prefs/" + BuildConfig.APPLICATION_ID + "_preferences.xml"); FileOutputStream output = new FileOutputStream(file); output.write(contents.getBytes()); output.close(); } catch (IOException e) { /* Gracefully fail */ } try { File file = new File(context.getFilesDir() + File.separator + "imported_successfully"); if (file.createNewFile()) LocalBroadcastManager.getInstance(context) .sendBroadcast(new Intent("com.farmerbb.taskbar.IMPORT_FINISHED")); } catch (IOException e) { /* Gracefully fail */ } } }
From source file:com.mobicage.rogerthat.NewsActivity.java
private void processNewsReceived(Intent intent, final NewsListAdapter nla) { if (swipeContainer.isRefreshing()) { swipeContainer.setRefreshing(false); resetUpdatesAvailable(nla, (Button) findViewById(R.id.updates_available)); } else if (isCurrentFeed(intent.getStringExtra("feed_name"))) { final boolean isInitial = intent.getBooleanExtra("initial", false); if (!isInitial) { final long[] newIds = intent.getLongArrayExtra("new_ids"); if (newIds != null) { for (long newsId : newIds) { mNewNewsItems.add(newsId); }//www . ja va 2 s . c o m if (newIds.length > 0) { setupUpdatesAvailable(); } } final long[] updatedIds = intent.getLongArrayExtra("updated_ids"); if (updatedIds != null) { nla.updateNewsItems(updatedIds); } } } }
From source file:com.android.contacts.group.GroupMembersFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode != Activity.RESULT_OK || data == null || requestCode != RESULT_GROUP_ADD_MEMBER) { return;/* ww w. j a v a 2s . com*/ } long[] contactIds = data.getLongArrayExtra(UiIntentActions.TARGET_CONTACT_IDS_EXTRA_KEY); if (contactIds == null) { final long contactId = data.getLongExtra(UiIntentActions.TARGET_CONTACT_ID_EXTRA_KEY, -1); if (contactId > -1) { contactIds = new long[1]; contactIds[0] = contactId; } } new UpdateGroupMembersAsyncTask(UpdateGroupMembersAsyncTask.TYPE_ADD, getContext(), contactIds, mGroupMetaData.groupId, mGroupMetaData.accountName, mGroupMetaData.accountType, mGroupMetaData.dataSet).execute(); }
From source file:com.lambdasoup.quickfit.alarm.AlarmService.java
@Override @WorkerThread//from w w w . j a v a 2s . c o m protected void onHandleIntent(Intent intent) { if (intent != null) { final String action = intent.getAction(); if (ACTION_ON_ALARM_RECEIVED.equals(action)) { handleOnAlarmReceived(intent); } else if (ACTION_ON_TIME_CHANGED.equals(action)) { handleOnTimeChanged(intent); } else if (ACTION_ON_NEXT_OCC_CHANGED.equals(action)) { handleOnNextOccChanged(); } else if (ACTION_ON_NOTIFICATIONS_CANCELED.equals(action)) { long[] scheduleIds = intent.getLongArrayExtra(EXTRA_SCHEDULE_IDS); handleOnNotificationsCanceled(scheduleIds); } else if (ACTION_ON_DID_IT.equals(action)) { long scheduleId = intent.getLongExtra(EXTRA_SCHEDULE_ID, -1); long workoutId = intent.getLongExtra(EXTRA_WORKOUT_ID, -1); handleOnDidIt(scheduleId, workoutId); } else if (ACTION_ON_SNOOZE.equals(action)) { long scheduleId = intent.getLongExtra(EXTRA_SCHEDULE_ID, -1); handleOnSnooze(scheduleId); } else { throw new IllegalArgumentException("Unexpected action " + action); } } }
From source file:com.bangz.smartmute.services.LocationMuteService.java
@Override protected void onHandleIntent(Intent intent) { if (intent != null) { final String action = intent.getAction(); if (ACTION_ADD_GEOFENCE.equals(action)) { handleAddGeofence(intent.getData()); } else if (ACTION_START_GEOFENCES.equals(action)) { handleStartGeofences();//from www . j a va2s.c om } else if (ACTION_GEODEFENCE_TRIGGER.equals(action)) { handleGeofenceTrigger(intent); } else if (ACTION_REMOVE_GEOFENCE.equals(action)) { handleRemoveGeofence(intent.getData()); } else if (ACTION_DELETE_GEOFENCES.equals(action)) { handleDeleteGeofences(intent.getLongArrayExtra(PARAM_KEY_IDS)); } } }
From source file:org.totschnig.myexpenses.fragment.TransactionList.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent intent) { if (requestCode == ProtectedFragmentActivity.FILTER_CATEGORY_REQUEST && resultCode != Activity.RESULT_CANCELED) { String label = intent.getStringExtra(KEY_LABEL); if (resultCode == Activity.RESULT_OK) { long catId = intent.getLongExtra(KEY_CATID, 0); addFilterCriteria(R.id.FILTER_CATEGORY_COMMAND, new CategoryCriteria(label, catId)); }/*from ww w .j ava2s. c o m*/ if (resultCode == Activity.RESULT_FIRST_USER) { long[] catIds = intent.getLongArrayExtra(KEY_CATID); addFilterCriteria(R.id.FILTER_CATEGORY_COMMAND, new CategoryCriteria(label, catIds)); } } }
From source file:com.yohpapa.research.simplemusicplayer.PlaybackService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { Log.d(TAG, "onStartCommand"); if (intent == null) { Log.d(TAG, "The intent is null."); return START_REDELIVER_INTENT; }//from ww w. jav a2s . co m String action = intent.getAction(); if (ACTION_PAUSE.equals(action)) { pauseTrack(); } else if (ACTION_PLAY.equals(action)) { playTrack(); } else if (ACTION_STOP.equals(action)) { stopTrack(); } else if (ACTION_SELECT.equals(action)) { int startIndex = intent.getIntExtra(PRM_START_INDEX, 0); long[] trackList = intent.getLongArrayExtra(PRM_TRACK_LIST); eventBus.post(new PrepareEvent(trackList, startIndex)); } else if (ACTION_TRACK_UP.equals(action)) { nextTrack(); } else if (ACTION_TRACK_DOWN.equals(action)) { prevTrack(); } return START_REDELIVER_INTENT; }
From source file:com.irccloud.android.RemoteInputService.java
@Override protected void onHandleIntent(Intent intent) { boolean success = false; String sk = getSharedPreferences("prefs", 0).getString("session_key", ""); if (intent != null && sk != null && sk.length() > 0) { final String action = intent.getAction(); if (ACTION_REPLY.equals(action)) { Bundle remoteInput = RemoteInput.getResultsFromIntent(intent); if (remoteInput != null || intent.hasExtra("reply")) { Crashlytics.log(Log.INFO, "IRCCloud", "Got reply from RemoteInput"); String reply = remoteInput != null ? remoteInput.getCharSequence("extra_reply").toString() : intent.getStringExtra("reply"); if (reply.length() > 0 && !reply.contains("\n/") && (!reply.startsWith("/") || reply.toLowerCase().startsWith("/me ") || reply.toLowerCase().startsWith("/slap "))) { try { JSONObject o = NetworkConnection.getInstance().say(intent.getIntExtra("cid", -1), intent.getStringExtra("to"), reply, sk); success = o.getBoolean("success"); } catch (Exception e) { e.printStackTrace(); }// www . j av a2 s . c o m } NotificationManagerCompat.from(IRCCloudApplication.getInstance().getApplicationContext()) .cancel(intent.getIntExtra("bid", 0)); if (intent.hasExtra("eids")) { int bid = intent.getIntExtra("bid", -1); long[] eids = intent.getLongArrayExtra("eids"); for (int j = 0; j < eids.length; j++) { if (eids[j] > 0) { Notifications.getInstance().dismiss(bid, eids[j]); } } } if (!success) Notifications.getInstance().alert(intent.getIntExtra("bid", -1), "Sending Failed", reply.startsWith("/") ? "Please launch the IRCCloud app to send this command" : "Your message was not sent. Please try again shortly."); } else { Crashlytics.log(Log.ERROR, "IRCCloud", "RemoteInputService received no remoteinput"); } } } }