List of usage examples for android.content Intent getLongExtra
public long getLongExtra(String name, long defaultValue)
From source file:com.daiv.android.twitter.services.SendTweet.java
@Override public int onStartCommand(Intent intent, int i, int x) { final Context context = this; final AppSettings settings = AppSettings.getInstance(this); try {//www . j a va2s .c om if (intent == null) { return START_NOT_STICKY; } } catch (Exception e) { // null pointer... what the hell } // set up the tweet from the intent message = intent.getStringExtra("message"); tweetId = intent.getLongExtra("tweet_id", 0l); remainingChars = intent.getIntExtra("char_remaining", 0); pwiccer = intent.getBooleanExtra("pwiccer", false); attachedUri = intent.getStringExtra("attached_uri"); secondAcc = intent.getBooleanExtra("second_account", false); if (attachedUri == null) { attachedUri = ""; } sendingNotification(); new Thread(new Runnable() { @Override public void run() { boolean sent = sendTweet(settings, context); if (sent) { finishedTweetingNotification(); } else { makeFailedNotification(message, settings); } finished = true; stopSelf(); } }).start(); // if it takes longer than 2 mins to preform the sending, then something is wrong and we will just shut it down. new Handler().postDelayed(new Runnable() { @Override public void run() { if (!finished) { stopForeground(true); makeFailedNotification(message, settings); stopSelf(); } } }, 120000); return START_STICKY; }
From source file:com.klinker.android.twitter.services.SendTweet.java
@Override public int onStartCommand(Intent intent, int i, int x) { final Context context = this; final AppSettings settings = AppSettings.getInstance(this); try {//from ww w .ja v a2 s . com if (intent == null) { return START_NOT_STICKY; } } catch (Exception e) { // null pointer... what the hell } // set up the tweet from the intent message = intent.getStringExtra("message"); tweetId = intent.getLongExtra("tweet_id", 0l); remainingChars = intent.getIntExtra("char_remaining", 0); pwiccer = intent.getBooleanExtra("pwiccer", false); attachedUri = intent.getStringExtra("attached_uri"); if (attachedUri == null) { attachedUri = ""; } sendingNotification(); new Thread(new Runnable() { @Override public void run() { boolean sent = sendTweet(settings, context); if (sent) { finishedTweetingNotification(); } else { makeFailedNotification(message, settings); } finished = true; stopSelf(); } }).start(); // if it takes longer than 2 mins to preform the sending, then something is wrong and we will just shut it down. new Handler().postDelayed(new Runnable() { @Override public void run() { if (!finished) { stopForeground(true); makeFailedNotification(message, settings); stopSelf(); } } }, 120000); return START_STICKY; }
From source file:io.plaidapp.ui.PlayerActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_dribbble_player); ButterKnife.bind(this); circleTransform = new CircleTransform(this); chromeFader = new ElasticDragDismissFrameLayout.SystemChromeFader(this); final Intent intent = getIntent(); if (intent.hasExtra(EXTRA_PLAYER)) { player = intent.getParcelableExtra(EXTRA_PLAYER); bindPlayer();//from w w w .java 2 s .com } else if (intent.hasExtra(EXTRA_PLAYER_NAME)) { String name = intent.getStringExtra(EXTRA_PLAYER_NAME); playerName.setText(name); if (intent.hasExtra(EXTRA_PLAYER_ID)) { long userId = intent.getLongExtra(EXTRA_PLAYER_ID, 0L); loadPlayer(userId); } else if (intent.hasExtra(EXTRA_PLAYER_USERNAME)) { String username = intent.getStringExtra(EXTRA_PLAYER_USERNAME); loadPlayer(username); } } else if (intent.getData() != null) { // todo support url intents } // setup immersive mode i.e. draw behind the system chrome & adjust insets draggableFrame.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION); draggableFrame.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() { @Override public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) { final ViewGroup.MarginLayoutParams lpFrame = (ViewGroup.MarginLayoutParams) draggableFrame .getLayoutParams(); lpFrame.leftMargin += insets.getSystemWindowInsetLeft(); // landscape lpFrame.rightMargin += insets.getSystemWindowInsetRight(); // landscape ((ViewGroup.MarginLayoutParams) avatar.getLayoutParams()).topMargin += insets .getSystemWindowInsetTop(); ViewUtils.setPaddingTop(container, insets.getSystemWindowInsetTop()); ViewUtils.setPaddingBottom(shots, insets.getSystemWindowInsetBottom()); // clear this listener so insets aren't re-applied draggableFrame.setOnApplyWindowInsetsListener(null); return insets; } }); setExitSharedElementCallback(FeedAdapter.createSharedElementReenterCallback(this)); }
From source file:org.klnusbaum.udj.network.EventCommService.java
private void enterEvent(Intent intent, AccountManager am, Account account, boolean attemptReauth) { if (!Utils.isNetworkAvailable(this)) { doLoginFail(am, account, EventJoinError.NO_NETWORK_ERROR); return;// ww w . j ava 2 s . co m } long userId, eventId; String authToken; //TODO hanle error if account isn't provided try { userId = Long.valueOf(am.getUserData(account, Constants.USER_ID_DATA)); //TODO handle if event id isn't provided authToken = am.blockingGetAuthToken(account, "", true); eventId = intent.getLongExtra(Constants.EVENT_ID_EXTRA, Constants.NO_EVENT_ID); } catch (OperationCanceledException e) { Log.e(TAG, "Operation canceled exception in EventCommService"); doLoginFail(am, account, EventJoinError.AUTHENTICATION_ERROR); return; } catch (AuthenticatorException e) { Log.e(TAG, "Authenticator exception in EventCommService"); doLoginFail(am, account, EventJoinError.AUTHENTICATION_ERROR); return; } catch (IOException e) { Log.e(TAG, "IO exception in EventCommService"); doLoginFail(am, account, EventJoinError.AUTHENTICATION_ERROR); return; } try { ServerConnection.joinEvent(eventId, userId, authToken); setEventData(intent, am, account); ContentResolver cr = getContentResolver(); UDJEventProvider.eventCleanup(cr); HashMap<Long, Long> previousRequests = ServerConnection.getAddRequests(userId, eventId, authToken); UDJEventProvider.setPreviousAddRequests(cr, previousRequests); JSONObject previousVotes = ServerConnection.getVoteRequests(userId, eventId, authToken); UDJEventProvider.setPreviousVoteRequests(cr, previousVotes); Intent joinedEventIntent = new Intent(Constants.JOINED_EVENT_ACTION); am.setUserData(account, Constants.LAST_EVENT_ID_DATA, String.valueOf(eventId)); am.setUserData(account, Constants.EVENT_STATE_DATA, String.valueOf(Constants.IN_EVENT)); sendBroadcast(joinedEventIntent); } catch (IOException e) { Log.e(TAG, "IO exception when joining event"); Log.e(TAG, e.getMessage()); doLoginFail(am, account, EventJoinError.SERVER_ERROR); } catch (JSONException e) { Log.e(TAG, "JSON exception when joining event"); Log.e(TAG, e.getMessage()); doLoginFail(am, account, EventJoinError.SERVER_ERROR); } catch (AuthenticationException e) { handleLoginAuthException(intent, am, account, authToken, attemptReauth); } catch (EventOverException e) { Log.e(TAG, "Event Over Exception when joining event"); //Log.e(TAG, e.getMessage()); doLoginFail(am, account, EventJoinError.EVENT_OVER_ERROR); } catch (AlreadyInEventException e) { Log.e(TAG, "Already In Event Exception when joining event"); try { ServerConnection.leaveEvent(e.getEventId(), userId, authToken); enterEvent(intent, am, account, true); } catch (AuthenticationException f) { handleLoginAuthException(intent, am, account, authToken, attemptReauth); } catch (IOException f) { Log.e(TAG, "IO exception when attempting to leave one event before " + "joining another"); Log.e(TAG, f.getMessage()); doLoginFail(am, account, EventJoinError.SERVER_ERROR); } } }
From source file:org.sufficientlysecure.ical.ui.MainActivity.java
private void initIntent() { Intent intent = getIntent(); if (intent == null) return;// w w w . jav a 2s . c o m String action = intent.getAction(); if (action.equals(LOAD_CALENDAR)) mIntentCalendarId = intent.getLongExtra(EXTRA_CALENDAR_ID, NO_CALENDAR); onExternalCalendarChanged(); if (action.equals(Intent.ACTION_VIEW)) setSource(null, intent.getData(), null, null); // File intent }
From source file:ru.yandex.subtitles.ui.activity.ConversationActivity.java
private void parseIntent(final Intent intent) { final String action = intent.getAction(); if (Intent.ACTION_SEND.equals(action)) { final boolean fromWidget = intent.getBooleanExtra(EXTRA_FROM_WIDGET, false); mMetadata.setFromWidget(fromWidget); final String phrase = intent.getStringExtra(Intent.EXTRA_TEXT); createConversationWithPhrase(phrase); } else if (Intent.ACTION_VIEW.equals(action)) { mThreadId = intent.getLongExtra(EXTRA_THREAD, ConversationFragment.STUB_CONVERSATION); showFragmentNoAnimate(ConversationFragment.newInstance(mThreadId, false, mMetadata), ConversationFragment.TAG); checkNetworkConnectivityState(); registerRecognitionReceiver();/*from w ww. ja va2 s . c o m*/ } else { // Fallback for no action case. Typically should never happen throw new IllegalStateException( "Please provide correct intent action to launch conversation activity."); } }
From source file:nz.ac.otago.psyanlab.common.PaleActivity.java
@Override public void onActivityResult(final int requestCode, final int resultCode, final Intent data) { switch (requestCode) { case REQUEST_IMPORT: switch (resultCode) { case RESULT_OK: handleImportedIds(data.getLongArrayExtra(ImportPaleActivity.RETURN_IDS)); break; default:/*from www.j a va 2s. c o m*/ break; } break; case REQUEST_NEW: switch (resultCode) { case RESULT_OK: { // Nothing let the list fragment know that we have a new // experiment and to choose it for the user. long experimentId = data.getLongExtra(Args.EXPERIMENT_ID, -1); mPaleListFragment.onExperimentInsert(experimentId); onItemSelected(experimentId); break; } default: { // We have to delete the experiment because it was // discarded by the user. long experimentId = data.getLongExtra(Args.EXPERIMENT_ID, -1); if (experimentId != -1) { try { mUserDelegate.getUserExperimentDelegate(experimentId).deleteExperiment(); } catch (IOException e) { e.printStackTrace(); throw new RuntimeException(e); } } else { throw new RuntimeException("Invalid experiment id."); } break; } } break; default: break; } }
From source file:com.ubikod.capptain.android.sdk.reach.CapptainReachAgent.java
/** * Get content by its intent (containing the content local identifier such as in intents * associated with the {@link #INTENT_ACTION_ACTION_NOTIFICATION} action). * @param intent intent containing the local identifier under the * {@value #INTENT_EXTRA_CONTENT_ID} extra key (as a long). * @return the content if found, null otherwise. *//*from www . j a v a 2 s .com*/ public <T extends CapptainReachContent> T getContent(Intent intent) { return getContent(intent.getLongExtra(INTENT_EXTRA_CONTENT_ID, 0)); }
From source file:org.awesomeapp.messenger.ui.ConversationDetailActivity.java
private void processIntent(Intent intent) { mApp = (ImApp) getApplication();/* w w w .ja va2s .co m*/ mChatId = intent.getLongExtra("id", -1); mAddress = intent.getStringExtra("address"); mNickname = intent.getStringExtra("nickname"); mConvoView.bindChat(mChatId, mAddress, mNickname); mConvoView.startListening(); //loadBackdrop(); // CollapsingToolbarLayout collapsingToolbar = // (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar); //collapsingToolbar.setTitle(mConvoView.getTitle()); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setTitle(mConvoView.getTitle()); //getSupportActionBar().setSubtitle("foo bar"); }
From source file:com.flowzr.activity.BudgetListFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { Log.i("flowzr", "entering on nactivity result"); if (requestCode == FILTER_BUDGET_REQUEST) { if (resultCode == MainActivity.RESULT_FIRST_USER) { filter.clear();//from w w w. ja v a 2 s. c o m } else if (resultCode == MainActivity.RESULT_OK) { String periodType = data.getStringExtra(DateFilterActivity.EXTRA_FILTER_PERIOD_TYPE); PeriodType p = PeriodType.valueOf(periodType); if (PeriodType.CUSTOM == p) { long periodFrom = data.getLongExtra(DateFilterActivity.EXTRA_FILTER_PERIOD_FROM, 0); long periodTo = data.getLongExtra(DateFilterActivity.EXTRA_FILTER_PERIOD_TO, 0); filter.put(new DateTimeCriteria(periodFrom, periodTo)); } else { filter.put(new DateTimeCriteria(p)); } } saveFilter(); } recreateAdapter(); recreateCursor(); if (resultCode != MainActivity.RESULT_CANCELED) { ((MainActivity) getActivity()).mAdapter.notifyDataSetChanged(); //getActivity().supportInvalidateOptionsMenu(); } }