List of usage examples for android.content Intent getLongExtra
public long getLongExtra(String name, long defaultValue)
From source file:mp.teardrop.LibraryActivity.java
/** * Adds songs matching the data from the given intent to the song timelime. * If given an intent built by DropboxAdapter, it will first retrieve streaming URLs * and ReplayGain info for all music files in the directory (or the one music file * the intent points to), since this Activity already has an instance of DropboxAPI. * * @param intent An intent created with//from w ww .j av a2s . c o m * {@link LibraryAdapter#createData(View)}. * If null, all songs in the MediaStore will be added. * @param action One of LibraryActivity.ACTION_* */ private void pickSongs(Intent intent, int action) { if (intent.getIntExtra(LibraryAdapter.DATA_TYPE, MediaUtils.TYPE_INVALID) == MediaUtils.TYPE_DROPBOX) { int mode = (action == ACTION_PLAY_ALL || action == ACTION_PLAY) ? ACTION_PLAY : ACTION_ENQUEUE; new DropboxPrepareMetadata((String) intent.getStringExtra(LibraryAdapter.DATA_FILE), modeForAction[mode]).execute(); return; } boolean all = false; int mode = action; if (action == ACTION_PLAY_ALL || action == ACTION_ENQUEUE_ALL) { if (mode == ACTION_ENQUEUE_ALL) { mode = ACTION_ENQUEUE; } else if (mode == ACTION_PLAY_ALL) { mode = ACTION_PLAY; } else { all = true; } } QueryTask query = (intent == null) ? MediaUtils.buildAllMediaQuery() : buildQueryFromIntent(intent, false, all); query.mode = modeForAction[mode]; PlaybackService.get(this).addSongs(query); mLastActedId = (intent == null) ? LibraryAdapter.INVALID_ID : intent.getLongExtra("id", LibraryAdapter.INVALID_ID); if (mDefaultAction == ACTION_LAST_USED && mLastAction != action) { mLastAction = action; } }
From source file:me.zchang.onchart.ui.MainActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); switch (requestCode) { // returned result from Settings Activity case REQ_SETTING: if (resultCode == RESULT_OK) { int returnWeekday = data.getIntExtra(getString(R.string.key_num_of_weekday), -1); int isLogout = data.getIntExtra(getString(R.string.key_logout), SettingsActivity.FLAG_NO_LOGOUT); /**/*from w w w . j a v a 2 s . c om*/ * 0 assign num of weekdays and setupFragments * 1 updateDrawer * 2 setupList */ boolean flags[] = new boolean[4]; if (returnWeekday != -1) { flags[0] = true; flags[2] = true; } if (isLogout != SettingsActivity.FLAG_NO_LOGOUT) { flags[1] = true; flags[2] = true; } for (int i = 0; i < flags.length; i++) { if (flags[i]) { switch (i) { case 0: numOfWeekdays = returnWeekday; setupFragments(); break; case 1: updateDrawer(); break; case 2: setupList(); updateWeekNumDisplay(); break; default: break; } } } } break; case REQ_POSITION: LessonListFragment curFragment = fragments.get(mainListPager.getCurrentItem()); int pos = data.getIntExtra(getString(R.string.intent_position), 0); if (resultCode == RESULT_OK) { LabelCourse course = (LabelCourse) curFragment .findCourseById(data.getLongExtra(getString(R.string.intent_course_id), -1)); if (course != null) { course.setLabelImgIndex(data.getIntExtra(getString(R.string.intent_label_image_index), 0)); course.resetColors(); curFragment.adapter.notifyItemChanged(pos); } if (curFragment == null) Log.e(TAG, "curFragment is null"); if (curFragment.adapter == null) Log.e(TAG, "adapater is null"); } break; } }
From source file:org.mariotaku.twidere.activity.support.ComposeActivity.java
private boolean handleIntent(final Intent intent) { final String action = intent.getAction(); if (action == null) return false; mShouldSaveAccounts = false;//from ww w .j a v a2s .c om mMentionUser = intent.getParcelableExtra(EXTRA_USER); mInReplyToStatus = intent.getParcelableExtra(EXTRA_STATUS); mInReplyToStatusId = mInReplyToStatus != null ? mInReplyToStatus.id : -1; switch (action) { case INTENT_ACTION_REPLY: { return handleReplyIntent(mInReplyToStatus); } case INTENT_ACTION_QUOTE: { return handleQuoteIntent(mInReplyToStatus); } case INTENT_ACTION_EDIT_DRAFT: { mDraftItem = intent.getParcelableExtra(EXTRA_DRAFT); return handleEditDraftIntent(mDraftItem); } case INTENT_ACTION_MENTION: { return handleMentionIntent(mMentionUser); } case INTENT_ACTION_REPLY_MULTIPLE: { final String[] screenNames = intent.getStringArrayExtra(EXTRA_SCREEN_NAMES); final long accountId = intent.getLongExtra(EXTRA_ACCOUNT_ID, -1); final long inReplyToUserId = intent.getLongExtra(EXTRA_IN_REPLY_TO_ID, -1); return handleReplyMultipleIntent(screenNames, accountId, inReplyToUserId); } case INTENT_ACTION_COMPOSE_TAKE_PHOTO: { return takePhoto(); } case INTENT_ACTION_COMPOSE_PICK_IMAGE: { return pickImage(); } } // Unknown action or no intent extras return false; }
From source file:com.javielinux.tweettopics2.TweetTopicsActivity.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, data); if (scanResult != null) { String result = scanResult.getContents(); if (result != null) { if (result.startsWith("tweettopics%%qr")) { importSearch(result);/* ww w. j a v a2 s. c om*/ } if (result.startsWith("tweettopics%%theme")) { importTheme(result); } } else { Utils.showMessage(this, getString(R.string.error_general)); } } switch (requestCode) { case ACTIVITY_NEWEDITSEARCH: if (data != null && data.getExtras() != null && data.getExtras().containsKey("view")) { boolean create_column = data.getExtras().getBoolean("view", false); if (create_column) { final int count = ColumnsUtils.nextPositionColumn(); Entity type = new Entity("type_columns", (long) TweetTopicsUtils.COLUMN_SEARCH); Entity search = new Entity("columns"); search.setValue("description", type.getString("description")); search.setValue("type_id", type); search.setValue("position", count); search.setValue("search_id", data.getLongExtra(DataFramework.KEY_ID, -1)); search.save(); goToColumn(count, true, -1); } else { getFragmentPagerAdapter().getMyActivityFragment().fillData(); } } break; case ACTIVITY_TRENDS_LOCATION: if (resultCode == Activity.RESULT_OK) { goToColumn(data.getIntExtra("position", 0), true, -1); } break; case ACTIVITY_EDIT_SEARCH: if (data != null && data.getExtras() != null && data.getExtras().containsKey("view")) { boolean view_column = data.getExtras().getBoolean("view", false); if (view_column) { Entity search_entity = new Entity("search", data.getLongExtra(DataFramework.KEY_ID, -1)); openSearchColumn(search_entity); } } break; case ACTIVITY_SHOW_USER_LISTS: if (resultCode == Activity.RESULT_OK && data != null) { final int position = data.getIntExtra("position", 0); Handler myHandler = new Handler(); myHandler.postDelayed(new Runnable() { @Override public void run() { getFragmentPagerAdapter().refreshColumnList(); refreshActionBarColumns(); getViewPager().setCurrentItem(position, false); } }, 100); } break; } }
From source file:org.mariotaku.twidere.fragment.support.StatusFragment.java
@Override public void onActivityResult(final int requestCode, final int resultCode, final Intent data) { final FragmentActivity activity = getActivity(); if (activity == null) return;/*from w w w. ja va 2s . c om*/ switch (requestCode) { case REQUEST_SET_COLOR: { final ParcelableStatus status = mStatusAdapter.getStatus(); if (status == null) return; final UserColorNameManager manager = UserColorNameManager.getInstance(activity); if (resultCode == Activity.RESULT_OK) { if (data == null) return; final int color = data.getIntExtra(EXTRA_COLOR, Color.TRANSPARENT); manager.setUserColor(status.user_id, color); } else if (resultCode == ColorPickerDialogActivity.RESULT_CLEARED) { manager.clearUserColor(status.user_id); } break; } case REQUEST_SELECT_ACCOUNT: { final ParcelableStatus status = mStatusAdapter.getStatus(); if (status == null) return; if (resultCode == Activity.RESULT_OK) { if (data == null || !data.hasExtra(EXTRA_ID)) return; final long accountId = data.getLongExtra(EXTRA_ID, -1); Utils.openStatus(activity, accountId, status.id); } break; } } }
From source file:it.feio.android.omninotes.DetailFragment.java
private void handleIntents() { Intent i = mainActivity.getIntent(); if (IntentChecker.checkAction(i, Constants.ACTION_MERGE)) { noteOriginal = new Note(); note = new Note(noteOriginal); noteTmp = getArguments().getParcelable(Constants.INTENT_NOTE); if (i.getStringArrayListExtra("merged_notes") != null) { mergedNotesIds = i.getStringArrayListExtra("merged_notes"); }/* w w w .j a v a 2 s .com*/ } // Action called from home shortcut if (IntentChecker.checkAction(i, Constants.ACTION_SHORTCUT, Constants.ACTION_NOTIFICATION_CLICK)) { afterSavedReturnsToList = false; noteOriginal = DbHelper.getInstance().getNote(i.getLongExtra(Constants.INTENT_KEY, 0)); // Checks if the note pointed from the shortcut has been deleted try { note = new Note(noteOriginal); noteTmp = new Note(noteOriginal); } catch (NullPointerException e) { mainActivity.showToast(getText(R.string.shortcut_note_deleted), Toast.LENGTH_LONG); mainActivity.finish(); } } // Check if is launched from a widget if (IntentChecker.checkAction(i, Constants.ACTION_WIDGET, Constants.ACTION_TAKE_PHOTO)) { afterSavedReturnsToList = false; showKeyboard = true; // with tags to set tag if (i.hasExtra(Constants.INTENT_WIDGET)) { String widgetId = i.getExtras().get(Constants.INTENT_WIDGET).toString(); if (widgetId != null) { String sqlCondition = prefs.getString(Constants.PREF_WIDGET_PREFIX + widgetId, ""); String categoryId = TextHelper.checkIntentCategory(sqlCondition); if (categoryId != null) { Category category; try { category = DbHelper.getInstance().getCategory(Long.parseLong(categoryId)); noteTmp = new Note(); noteTmp.setCategory(category); } catch (NumberFormatException e) { Log.e(Constants.TAG, "Category with not-numeric value!", e); } } } } // Sub-action is to take a photo if (IntentChecker.checkAction(i, Constants.ACTION_TAKE_PHOTO)) { takePhoto(); } } /** * Handles third party apps requests of sharing */ if (IntentChecker.checkAction(i, Intent.ACTION_SEND, Intent.ACTION_SEND_MULTIPLE, Constants.INTENT_GOOGLE_NOW) && i.getType() != null) { afterSavedReturnsToList = false; if (noteTmp == null) noteTmp = new Note(); // Text title String title = i.getStringExtra(Intent.EXTRA_SUBJECT); if (title != null) { noteTmp.setTitle(title); } // Text content String content = i.getStringExtra(Intent.EXTRA_TEXT); if (content != null) { noteTmp.setContent(content); } // Single attachment data Uri uri = i.getParcelableExtra(Intent.EXTRA_STREAM); // Due to the fact that Google Now passes intent as text but with // audio recording attached the case must be handled in specific way if (uri != null && !Constants.INTENT_GOOGLE_NOW.equals(i.getAction())) { String name = FileHelper.getNameFromUri(mainActivity, uri); AttachmentTask task = new AttachmentTask(this, uri, name, this); task.execute(); } // Multiple attachment data ArrayList<Uri> uris = i.getParcelableArrayListExtra(Intent.EXTRA_STREAM); if (uris != null) { for (Uri uriSingle : uris) { String name = FileHelper.getNameFromUri(mainActivity, uriSingle); AttachmentTask task = new AttachmentTask(this, uriSingle, name, this); task.execute(); } } // i.setAction(null); } if (IntentChecker.checkAction(i, Intent.ACTION_MAIN, Constants.ACTION_WIDGET_SHOW_LIST)) { showKeyboard = true; } }
From source file:org.getlantern.firetweet.fragment.support.UserFragment.java
@Override public void onActivityResult(final int requestCode, final int resultCode, final Intent data) { final ParcelableUser user = getUser(); switch (requestCode) { case REQUEST_SET_COLOR: { if (user == null) return; if (resultCode == Activity.RESULT_OK) { if (data == null) return; final int color = data.getIntExtra(EXTRA_COLOR, Color.TRANSPARENT); UserColorNameUtils.setUserColor(getActivity(), mUser.id, color); } else if (resultCode == ColorPickerDialogActivity.RESULT_CLEARED) { clearUserColor(getActivity(), mUser.id); }//from www . j a v a 2 s .c om break; } case REQUEST_ADD_TO_LIST: { if (user == null) return; if (resultCode == Activity.RESULT_OK && data != null) { final AsyncTwitterWrapper twitter = getTwitterWrapper(); final ParcelableUserList list = data.getParcelableExtra(EXTRA_USER_LIST); if (list == null || twitter == null) return; twitter.addUserListMembersAsync(user.account_id, list.id, user); } break; } case REQUEST_SELECT_ACCOUNT: { if (user == null) return; if (resultCode == Activity.RESULT_OK) { if (data == null || !data.hasExtra(EXTRA_ID)) return; final long accountId = data.getLongExtra(EXTRA_ID, -1); openUserProfile(getActivity(), accountId, user.id, user.screen_name, null); } break; } } }
From source file:com.dycody.android.idealnote.DetailFragment.java
private void handleIntents() { Intent i = mainActivity.getIntent(); if (IntentChecker.checkAction(i, Constants.ACTION_MERGE)) { noteOriginal = new Note(); note = new Note(noteOriginal); noteTmp = getArguments().getParcelable(Constants.INTENT_NOTE); if (i.getStringArrayListExtra("merged_notes") != null) { mergedNotesIds = i.getStringArrayListExtra("merged_notes"); }//w w w.j a v a 2s . co m } // Action called from home shortcut if (IntentChecker.checkAction(i, Constants.ACTION_SHORTCUT, Constants.ACTION_NOTIFICATION_CLICK)) { afterSavedReturnsToList = false; noteOriginal = DbHelper.getInstance().getNote(i.getLongExtra(Constants.INTENT_KEY, 0)); // Checks if the note pointed from the shortcut has been deleted try { note = new Note(noteOriginal); noteTmp = new Note(noteOriginal); } catch (NullPointerException e) { mainActivity.showToast(getText(R.string.shortcut_note_deleted), Toast.LENGTH_LONG); mainActivity.finish(); } } // Check if is launched from a widget if (IntentChecker.checkAction(i, Constants.ACTION_WIDGET, Constants.ACTION_TAKE_PHOTO)) { afterSavedReturnsToList = false; showKeyboard = true; // with tags to set tag if (i.hasExtra(Constants.INTENT_WIDGET)) { String widgetId = i.getExtras().get(Constants.INTENT_WIDGET).toString(); if (widgetId != null) { String sqlCondition = prefs.getString(Constants.PREF_WIDGET_PREFIX + widgetId, ""); String categoryId = TextHelper.checkIntentCategory(sqlCondition); if (categoryId != null) { Category category; try { category = DbHelper.getInstance().getCategory(Long.parseLong(categoryId)); noteTmp = new Note(); noteTmp.setCategory(category); } catch (NumberFormatException e) { Log.e(Constants.TAG, "Category with not-numeric value!", e); } } } } // Sub-action is to take a photo if (IntentChecker.checkAction(i, Constants.ACTION_TAKE_PHOTO)) { takePhoto(); } } /** * Handles third party apps requests of sharing */ if (IntentChecker.checkAction(i, Intent.ACTION_SEND, Intent.ACTION_SEND_MULTIPLE, Constants.INTENT_GOOGLE_NOW) && i.getType() != null) { afterSavedReturnsToList = false; if (noteTmp == null) noteTmp = new Note(); // Text title String title = i.getStringExtra(Intent.EXTRA_SUBJECT); if (title != null) { noteTmp.setTitle(title); } // Text content String content = i.getStringExtra(Intent.EXTRA_TEXT); if (content != null) { noteTmp.setContent(content); } // Single attachment data Uri uri = i.getParcelableExtra(Intent.EXTRA_STREAM); // Due to the fact that Google Now passes intent as text but with // audio recording attached the case must be handled in specific way if (uri != null && !Constants.INTENT_GOOGLE_NOW.equals(i.getAction())) { String name = FileHelper.getNameFromUri(mainActivity, uri); new AttachmentTask(this, uri, name, this).execute(); } // Multiple attachment data ArrayList<Uri> uris = i.getParcelableArrayListExtra(Intent.EXTRA_STREAM); if (uris != null) { for (Uri uriSingle : uris) { String name = FileHelper.getNameFromUri(mainActivity, uriSingle); new AttachmentTask(this, uriSingle, name, this).execute(); } } } if (IntentChecker.checkAction(i, Intent.ACTION_MAIN, Constants.ACTION_WIDGET_SHOW_LIST, Constants.ACTION_SHORTCUT_WIDGET, Constants.ACTION_WIDGET)) { showKeyboard = true; } i.setAction(null); }
From source file:org.kontalk.service.msgcenter.MessageCenterService.java
@CommandHandler(name = ACTION_MEDIA_READY) private boolean handleMediaReady(Intent intent) { long msgId = intent.getLongExtra("org.kontalk.message.msgId", 0); if (msgId > 0) sendReadyMedia(msgId);// w w w .ja v a 2 s . co m return true; }
From source file:org.tvheadend.tvhclient.htsp.HTSService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { final String action = intent.getAction(); if (action.equals(Constants.ACTION_CONNECT)) { boolean force = intent.getBooleanExtra("force", false); boolean async = intent.getBooleanExtra("async", true); final String hostname = intent.getStringExtra("hostname"); final int port = intent.getIntExtra("port", 9982); final String username = intent.getStringExtra("username"); final String password = intent.getStringExtra("password"); if (connection != null && force) { connection.close();/*from ww w .j a va 2 s . c o m*/ } if (connection == null || !connection.isConnected()) { final TVHClientApplication app = (TVHClientApplication) getApplication(); app.clearAll(); app.setLoading(true); connection = new HTSConnection(this, packInfo.packageName, packInfo.versionName, async); // Since this is blocking, spawn to a new thread execService.execute(new Runnable() { public void run() { connection.open(hostname, port); connection.authenticate(username, password); } }); } } else if (connection == null || !connection.isConnected()) { Log.e(TAG, "No connection to perform " + action); } else if (action.equals(Constants.ACTION_DISCONNECT)) { connection.close(); } else if (action.equals(Constants.ACTION_GET_EVENT)) { getEvent(intent.getLongExtra("eventId", 0)); } else if (action.equals(Constants.ACTION_GET_EVENTS)) { TVHClientApplication app = (TVHClientApplication) getApplication(); final Channel ch = app.getChannel(intent.getLongExtra("channelId", 0)); getEvents(ch, intent.getLongExtra("eventId", 0), intent.getIntExtra("count", 10)); } else if (action.equals(Constants.ACTION_ADD_DVR_ENTRY)) { TVHClientApplication app = (TVHClientApplication) getApplication(); Channel ch = app.getChannel(intent.getLongExtra("channelId", 0)); addDvrEntry(ch, intent.getLongExtra("eventId", 0)); } else if (action.equals(Constants.ACTION_DELETE_DVR_ENTRY)) { deleteDvrEntry(Integer.valueOf(intent.getStringExtra("id"))); } else if (action.equals(Constants.ACTION_CANCEL_DVR_ENTRY)) { cancelDvrEntry(intent.getLongExtra("id", 0)); } else if (action.equals(Constants.ACTION_ADD_TIMER_REC_ENTRY)) { addTimerRecEntry(intent.getStringExtra("title"), intent.getLongExtra("start", 0), intent.getLongExtra("stop", 0), intent.getLongExtra("channelId", 0), intent.getStringExtra("configName"), intent.getLongExtra("retention", 0), intent.getLongExtra("daysOfWeek", 0), intent.getLongExtra("priority", 0), intent.getLongExtra("enabled", 0), intent.getStringExtra("name"), intent.getStringExtra("directory")); } else if (action.equals(Constants.ACTION_DELETE_TIMER_REC_ENTRY)) { deleteTimerRecEntry(intent.getStringExtra("id")); } else if (action.equals(Constants.ACTION_EPG_QUERY)) { TVHClientApplication app = (TVHClientApplication) getApplication(); Channel ch = app.getChannel(intent.getLongExtra("channelId", 0)); epgQuery(ch, intent.getStringExtra("query"), intent.getLongExtra("tagId", 0)); } else if (action.equals(Constants.ACTION_SUBSCRIBE)) { subscribe(intent.getLongExtra("channelId", 0), intent.getLongExtra("subscriptionId", 0), intent.getIntExtra("maxWidth", 0), intent.getIntExtra("maxHeight", 0), intent.getStringExtra("audioCodec"), intent.getStringExtra("videoCodec")); } else if (action.equals(Constants.ACTION_UNSUBSCRIBE)) { unsubscribe(intent.getLongExtra("subscriptionId", 0)); } else if (action.equals(Constants.ACTION_FEEDBACK)) { feedback(intent.getLongExtra("subscriptionId", 0), intent.getIntExtra("speed", 0)); } else if (action.equals(Constants.ACTION_GET_TICKET)) { TVHClientApplication app = (TVHClientApplication) getApplication(); Channel ch = app.getChannel(intent.getLongExtra("channelId", 0)); Recording rec = app.getRecording(intent.getLongExtra("dvrId", 0)); if (ch != null) { getTicket(ch); } else if (rec != null) { getTicket(rec); } } else if (action.equals(Constants.ACTION_GET_DISC_SPACE)) { getDiscSpace(); } else if (action.equals(Constants.ACTION_GET_DVR_CONFIG)) { getDvrConfigs(); } else if (action.equals(Constants.ACTION_GET_PROFILES)) { getProfiles(); } else if (action.equals(Constants.ACTION_GET_CHANNEL)) { TVHClientApplication app = (TVHClientApplication) getApplication(); Channel ch = app.getChannel(intent.getLongExtra("channelId", 0)); if (ch != null) { getChannel(ch); } } else if (action.equals(Constants.ACTION_SUBSCRIBE_FILTER_STREAM)) { subscriptionFilterStream(); } else if (action.equals(Constants.ACTION_GET_DVR_CUTPOINTS)) { TVHClientApplication app = (TVHClientApplication) getApplication(); Recording rec = app.getRecording(intent.getLongExtra("dvrId", 0)); if (rec != null) { getDvrCutpoints(rec); } } else if (action.equals(Constants.ACTION_ADD_SERIES_DVR_ENTRY)) { addAutorecEntry(intent.getStringExtra("title"), intent.getLongExtra("channelId", 0), intent.getStringExtra("configName"), intent.getLongExtra("maxDuration", 0), intent.getLongExtra("minDuration", 0), intent.getLongExtra("retention", 0), intent.getLongExtra("daysOfWeek", 127), intent.getLongExtra("priority", 0), intent.getLongExtra("enabled", 1), intent.getLongExtra("startExtra", 0), intent.getLongExtra("stopExtra", 0), intent.getStringExtra("name"), intent.getStringExtra("directory")); } else if (action.equals(Constants.ACTION_DELETE_SERIES_DVR_ENTRY)) { String id = intent.getStringExtra("id"); deleteAutorecEntry(id); } else if (action.equals(Constants.ACTION_GET_SYSTEM_TIME)) { getSystemTime(); } return START_NOT_STICKY; }