List of usage examples for android.content Intent getLongExtra
public long getLongExtra(String name, long defaultValue)
From source file:net.kjmaster.cookiemom.MainActivity.java
@OnActivityResult(Constants.REMOVE_SCOUT_REQUEST_CODE) void onRemoveScout(int resultCode, Intent data) { if (resultCode == RESULT_OK) { if (data != null) { long scout_id = data.getLongExtra("scout_id", 0); long target_id = data.getLongExtra("target_id", 0); List<BoothAssignments> list = Main.daoSession.getBoothAssignmentsDao().queryBuilder() .where(BoothAssignmentsDao.Properties.BoothAssignScoutId.eq(scout_id), BoothAssignmentsDao.Properties.BoothAssignBoothId.eq(target_id)) .list();/*ww w . j ava 2s. co m*/ for (BoothAssignments assignments : list) { Main.daoSession.getBoothAssignmentsDao().delete(assignments); } } } }
From source file:de.bno.snakingnumbers.MainMenu.java
private void onGameResult(int resultCode, Intent data) { Log.d(MainMenu.class.getName(), "GameResult " + resultCode); if (resultCode == RESULT_OK) { long elapsedTime = data.getLongExtra(Game.EXTRA_ELAPSED_TIME, -1); int difficulty = data.getIntExtra(Game.EXTRA_DIFFICULTY, -1); int clickCount = data.getIntExtra(Game.EXTRA_CLICK_COUNT, -1); int maxNumber = data.getIntExtra(Game.EXTRA_MAX_NUMBER, -1); Log.d(MainMenu.class.getName(), "GameResult [elapsedTime, difficulty, clickCount, maxNumber] " + elapsedTime + " " + difficulty + " " + clickCount + " " + maxNumber); if (elapsedTime > -1 && difficulty > -1 && clickCount > -1 && maxNumber > -1) { gotoResultActivity(difficulty, elapsedTime, clickCount, maxNumber); }/*from www. j a v a 2s . c o m*/ } }
From source file:com.slx.funstream.ui.streams.StreamActivity.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == RC_LOGIN) { if (resultCode == RESULT_OK) { if (data.hasExtra(LoginFragment.FIELD_TOKEN) && data.hasExtra(LoginFragment.FIELD_USERID)) { CurrentUser user = new CurrentUser(); Long userId = data.getLongExtra(LoginFragment.FIELD_USERID, DEFAULT_NON_EXISTING_VALUE); // Check if something went wrong if (userId == DEFAULT_NON_EXISTING_VALUE) { Toaster.makeLongToast(this, getString(R.string.error_login)); return; }//from ww w .j ava2 s . c o m user.setId(userId); user.setName(data.getStringExtra(LoginFragment.FIELD_USERNAME)); user.setToken(data.getStringExtra(LoginFragment.FIELD_TOKEN)); prefUtils.saveUser(user); userStore.fetchUser(); invalidateOptionsMenu(); } } } }
From source file:eu.inmite.apps.smsjizdenka.activity.MainActivity.java
@Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); handleIntent(intent);/*from ww w.j a v a2s .co m*/ if (mCurrentFragment != null && getSupportActionBar().getSelectedNavigationIndex() == TAB_TICKETS) { ((TicketsFragment) mCurrentFragment).collapseUncollapseTicket( intent.getLongExtra(EXTRA_TICKET_ID, TicketsFragment.NONE), intent.getBooleanExtra(EXTRA_SHOW_SMS, false)); } else { getSupportActionBar().setSelectedNavigationItem(TAB_TICKETS); } }
From source file:com.concentricsky.android.khanacademy.data.KADataService.java
private void updateDownloadStatus(Intent intent, final PendingIntent pendingIntent, final int startId) { final long id = intent.getLongExtra(EXTRA_ID, -1); final DownloadManager mgr = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE); final DownloadManager.Query q = new DownloadManager.Query(); q.setFilterById(id);//from ww w . ja v a2s .c o m new AsyncTask<Void, Void, Boolean>() { @Override protected Boolean doInBackground(Void... arg) { Cursor cursor = mgr.query(q); String youtubeId = null; int status = -1; if (cursor.moveToFirst()) { String filename = cursor .getString(cursor.getColumnIndex(DownloadManager.COLUMN_LOCAL_FILENAME)); youtubeId = OfflineVideoManager.youtubeIdFromFilename(filename); status = cursor.getInt(cursor.getColumnIndex(DownloadManager.COLUMN_STATUS)); } cursor.close(); if (status == DownloadManager.STATUS_SUCCESSFUL && youtubeId != null) { try { Dao<Video, String> videoDao = helper.getVideoDao(); UpdateBuilder<Video, String> q = videoDao.updateBuilder(); q.where().eq("youtube_id", youtubeId); q.updateColumnValue("download_status", Video.DL_STATUS_COMPLETE); q.update(); return true; } catch (SQLException e) { e.printStackTrace(); } } return false; } @Override protected void onPostExecute(Boolean successful) { if (successful) { broadcastOfflineVideoSetChanged(); finish(startId, pendingIntent, RESULT_SUCCESS); } else { finish(startId, pendingIntent, RESULT_ERROR); } } }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }
From source file:com.fabernovel.alertevoirie.ExistingIncidentsActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == RESULT_OK) { if (getIntent().getBooleanExtra(Constants.NEW_REPORT, false)) { Intent i = new Intent(this, ReportDetailsActivity.class); i.putExtra(IntentData.EXTRA_CATEGORY_ID, data.getLongExtra(IntentData.EXTRA_CATEGORY_ID, -1)); startActivity(i);/*w w w . j a v a 2 s. c o m*/ } Log.d(Constants.PROJECT_TAG, "Result: " + data.getLongExtra(IntentData.EXTRA_CATEGORY_ID, -1)); finish(); } }
From source file:com.example.ivonneortega.the_news_project.detailView.CollectionDemoActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setTheme();//ww w . j a v a 2 s . c o m Intent intent = getIntent(); mId = intent.getLongExtra(DatabaseHelper.COL_ID, -1); String type = intent.getStringExtra(TYPE_OF_INTENT); mArticle = DatabaseHelper.getInstance(this).getArticlesById(mId); mArticle = DatabaseHelper.getInstance(this).getArticlesById(mId); if (type.equalsIgnoreCase("allStories")) articleList = DatabaseHelper.getInstance(this).getArticlesByCategory(mArticle.getCategory()); else if (type.equalsIgnoreCase("save")) articleList = DatabaseHelper.getInstance(this).getSavedArticles(); else if (type.equalsIgnoreCase("top")) articleList = DatabaseHelper.getInstance(this).getTopStoryArticles(); mPosition = Article.getArticlePosition(mId, articleList); creatingViews(); }
From source file:be.benvd.mvforandroid.data.MVDataService.java
/** * Does the actual work./*from w w w . ja v a 2s. com*/ */ @Override protected void doWakefulWork(Intent intent) { String action = intent.getAction(); try { if (action.equals(UPDATE_CREDIT)) { updateCredit(); } else if (action.equals(UPDATE_TOPUPS)) { updateTopups(); } else if (action.equals(UPDATE_USAGE)) { updateUsage(intent.getLongExtra(UPDATE_USAGE_STARTTIME, 0), intent.getLongExtra(UPDATE_USAGE_ENDTIME, 0)); } else if (action.equals(UPDATE_ALL)) { if (prefs.getBoolean("auto_credit", true)) updateCredit(); if (prefs.getBoolean("auto_usage", false)) updateUsage(); if (prefs.getBoolean("auto_topups", false)) updateTopups(); scheduleNextUpdate(); } else if (action.equals(STOP_SERVICE)) { Log.v(MVDataService.class.getSimpleName(), "Update canceled"); alarm.cancel(wakefulWorkIntent); stopSelf(); } else if (action.equals(SCHEDULE_SERVICE)) { scheduleNextUpdate(); } } catch (IOException e) { exceptionBroadcast.putExtra(EXCEPTION, e); sendBroadcast(exceptionBroadcast); } catch (JSONException e) { exceptionBroadcast.putExtra(EXCEPTION, e); sendBroadcast(exceptionBroadcast); } }
From source file:org.anhonesteffort.flock.CalendarCopyService.java
private void handleQueueCalendarForCopy(Intent intent) { Log.d(TAG, "handleQueueCalendarForCopy()"); Account fromAccount = intent.getParcelableExtra(KEY_FROM_ACCOUNT); Account toAccount = intent.getParcelableExtra(KEY_TO_ACCOUNT); Long calendarId = intent.getLongExtra(KEY_CALENDAR_ID, -1); String calendarName = intent.getStringExtra(KEY_CALENDAR_NAME); Integer calendarColor = intent.getIntExtra(KEY_CALENDAR_COLOR, 0); Integer eventCount = intent.getIntExtra(KEY_EVENT_COUNT, -1); if (fromAccount == null || toAccount == null || calendarId < 0 || calendarName == null || eventCount < 0) { Log.e(TAG, "failed to parse to account, from account, calendar id, calendar " + "label, calendar color or event count from intent extras."); return;//from w w w .j a v a 2 s .c o m } accountsForCopy.add(new AccountForCopy(fromAccount, toAccount, calendarId, calendarName, calendarColor)); calendarsForCopy.add(new CalendarForCopy(fromAccount, calendarId, eventCount)); countEventsToCopy += eventCount; Log.d(TAG, "events to copy: " + countEventsToCopy); }
From source file:org.dodgybits.shuffle.android.view.fragment.TaskPagerFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { Log.d(TAG, "Got resultCode " + resultCode + " with data " + data); switch (requestCode) { case DEFERRED_CODE: if (resultCode == Activity.RESULT_OK) { if (data != null) { long deferred = data.getLongExtra(DateTimePickerActivity.DATETIME_VALUE, 0L); Task.Builder builder = Task.newBuilder().mergeFrom(getSelectedTask()).setStartDate(deferred); builder.getChangeSet().showFromChanged(); mTaskPersister.update(builder.build()); }// ww w .j a v a 2 s. c o m } break; default: Log.e(TAG, "Unknown requestCode: " + requestCode); } }