List of usage examples for android.content Intent getLongExtra
public long getLongExtra(String name, long defaultValue)
From source file:org.runnerup.view.DetailActivity.java
/** Called when the activity is first created. */ @Override// w w w. j a va 2 s . c o m public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.detail); WidgetUtil.addLegacyOverflowButton(getWindow()); Intent intent = getIntent(); mID = intent.getLongExtra("ID", -1); String mode = intent.getStringExtra("mode"); mDBHelper = new DBHelper(this); mDB = mDBHelper.getReadableDatabase(); uploadManager = new UploadManager(this); formatter = new Formatter(this); if (mode.contentEquals("save")) { this.mode = MODE_SAVE; } else if (mode.contentEquals("details")) { this.mode = MODE_DETAILS; } else { assert (false); } saveButton = (Button) findViewById(R.id.save_button); discardButton = (Button) findViewById(R.id.discard_button); resumeButton = (Button) findViewById(R.id.resume_button); uploadButton = (Button) findViewById(R.id.upload_button); activityTime = (TextView) findViewById(R.id.activity_time); activityDistance = (TextView) findViewById(R.id.activity_distance); activityPace = (TextView) findViewById(R.id.activity_pace); sport = (TitleSpinner) findViewById(R.id.summary_sport); notes = (EditText) findViewById(R.id.notes_text); notes.setHint("Notes about your workout"); map = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap(); if (map != null) { map.setOnCameraChangeListener(new OnCameraChangeListener() { @Override public void onCameraChange(CameraPosition arg0) { if (mapBounds != null) { // Move camera. map.moveCamera(CameraUpdateFactory.newLatLngBounds(mapBounds, 5)); // Remove listener to prevent position reset on camera // move. map.setOnCameraChangeListener(null); } } }); } saveButton.setOnClickListener(saveButtonClick); uploadButton.setOnClickListener(uploadButtonClick); if (this.mode == MODE_SAVE) { resumeButton.setOnClickListener(resumeButtonClick); discardButton.setOnClickListener(discardButtonClick); setEdit(true); } else if (this.mode == MODE_DETAILS) { resumeButton.setVisibility(View.GONE); discardButton.setVisibility(View.GONE); setEdit(false); } uploadButton.setVisibility(View.GONE); fillHeaderData(); requery(); loadRoute(); TabHost th = (TabHost) findViewById(R.id.tabhost); th.setup(); TabSpec tabSpec = th.newTabSpec("notes"); tabSpec.setIndicator(WidgetUtil.createHoloTabIndicator(this, "Notes")); tabSpec.setContent(R.id.tab_main); th.addTab(tabSpec); tabSpec = th.newTabSpec("laps"); tabSpec.setIndicator(WidgetUtil.createHoloTabIndicator(this, "Laps")); tabSpec.setContent(R.id.tab_lap); th.addTab(tabSpec); tabSpec = th.newTabSpec("map"); tabSpec.setIndicator(WidgetUtil.createHoloTabIndicator(this, "Map")); tabSpec.setContent(R.id.tab_map); th.addTab(tabSpec); tabSpec = th.newTabSpec("graph"); tabSpec.setIndicator(WidgetUtil.createHoloTabIndicator(this, "Graph")); tabSpec.setContent(R.id.tab_graph); th.addTab(tabSpec); tabSpec = th.newTabSpec("share"); tabSpec.setIndicator(WidgetUtil.createHoloTabIndicator(this, "Upload")); tabSpec.setContent(R.id.tab_upload); th.addTab(tabSpec); th.getTabWidget().setBackgroundColor(Color.DKGRAY); { ListView lv = (ListView) findViewById(R.id.laplist); LapListAdapter adapter = new LapListAdapter(); adapters.add(adapter); lv.setAdapter(adapter); } { ListView lv = (ListView) findViewById(R.id.report_list); ReportListAdapter adapter = new ReportListAdapter(); adapters.add(adapter); lv.setAdapter(adapter); } graphTab = (LinearLayout) findViewById(R.id.tab_graph); { graphView = new LineGraphView(this, "Pace") { @Override protected String formatLabel(double value, boolean isValueX) { if (!isValueX) { return formatter.formatPace(Formatter.TXT_SHORT, value); } else return formatter.formatDistance(Formatter.TXT_SHORT, (long) value); } }; graphView2 = new LineGraphView(this, "HRM") { @Override protected String formatLabel(double value, boolean isValueX) { if (!isValueX) { return Integer.toString((int) Math.round(value)); } else { return formatter.formatDistance(Formatter.TXT_SHORT, (long) value); } } }; } hrzonesBarLayout = (LinearLayout) findViewById(R.id.hrzonesBarLayout); hrzonesBar = new HRZonesBar(this); }
From source file:alaindc.crowdroid.SendIntentService.java
@Override protected void onHandleIntent(Intent intent) { if (intent != null) { final String action = intent.getAction(); // DIFFERENTIATE like in sensorIntentService per each sensor! if (action.startsWith(Constants.ACTION_SENDDATA)) { handleActionSendData(intent.getIntExtra(Constants.EXTRA_TYPE_OF_SENSOR_TO_SEND, -1)); // Name in shared preference } else if (action.startsWith(Constants.ACTION_RECEIVEDDATA)) { final String response = intent.getStringExtra(Constants.EXTRA_SENSE_RESPONSE); handleActionReceivedData(response); } else if (action.startsWith(Constants.ACTION_GETSUBSCRIPTION)) { handleActionGetSubscriptions(); } else if (action.startsWith(Constants.ACTION_UPDATESUBSCRIPTION)) { handleActionUpdateSubscriptions(intent.getStringExtra(Constants.EXTRA_BODY_UPDATESUBSCRIPTION)); } else if (action.startsWith(Constants.ACTION_RECEIVEDSUBSCRIPTION)) { handleActionReceivedSubscriptions(intent.getStringExtra(Constants.EXTRA_SUBSCRIPTION_RESPONSE)); } else if (action.startsWith(Constants.ACTION_RECEIVEDTHROUGHPUT)) { handleActionReceivedThroughput(intent.getLongExtra(Constants.EXTRA_THROUGHPUT_RESPONSE, -1)); }//from w w w . j a v a 2s . com } }
From source file:com.nnm.smsviet.MessageListActivity.java
/** * Parse data pushed by {@link Intent}.//from w w w. ja v a 2 s. co m * * @param intent * {@link Intent} */ private void parseIntent(final Intent intent) { Log.d(TAG, "parseIntent(" + intent + ")"); if (intent == null) { return; } Log.d(TAG, "got action: " + intent.getAction()); Log.d(TAG, "got uri: " + intent.getData()); this.needContactUpdate = true; this.uri = intent.getData(); if (this.uri != null) { if (!this.uri.toString().startsWith(URI)) { this.uri = Uri.parse(URI + this.uri.getLastPathSegment()); } } else { final long tid = intent.getLongExtra("thread_id", -1L); this.uri = Uri.parse(URI + tid); if (tid < 0L) { try { this.startActivity(ConversationListActivity.getComposeIntent(this, null)); } catch (ActivityNotFoundException e) { Log.e(TAG, "activity not found", e); Toast.makeText(this, R.string.error_conv_null, Toast.LENGTH_LONG).show(); } this.finish(); return; } } this.getLastPathSegment = Integer.parseInt(this.uri.getLastPathSegment()); final int threadId = Integer.parseInt(this.uri.getLastPathSegment()); final Conversation c = Conversation.getConversation(this, threadId, true); this.conv = c; if (c == null) { Toast.makeText(this, R.string.error_conv_null, Toast.LENGTH_LONG).show(); this.finish(); return; } final Contact contact = c.getContact(); contact.update(this, false, true); Log.d(TAG, "address: " + contact.getNumber()); Log.d(TAG, "name: " + contact.getName()); Log.d(TAG, "displayName: " + contact.getDisplayName()); final ListView lv = this.getListView(); lv.setStackFromBottom(true); MessageAdapter adapter = new MessageAdapter(this, this.uri); this.setListAdapter(adapter); String displayName = contact.getDisplayName(); this.setTitle(displayName); String number = contact.getNumber(); if (displayName.equals(number)) { this.getSupportActionBar().setSubtitle(null); } else { this.getSupportActionBar().setSubtitle(number); } this.setContactIcon(contact); final String body = intent.getStringExtra(Intent.EXTRA_TEXT); if (!TextUtils.isEmpty(body)) { this.etText.setText(body); } this.setRead(); }
From source file:org.cm.podd.report.activity.ReportActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); LocalBroadcastManager broadcastManager = LocalBroadcastManager.getInstance(this); broadcastManager.registerReceiver(mAlertReceiver, new IntentFilter(FollowAlertService.TAG)); broadcastManager.registerReceiver(new BroadcastReceiver() { @Override/*ww w . j a v a2 s .c om*/ public void onReceive(Context context, Intent intent) { long administrationAreaId = intent.getLongExtra("administrationAreaId", -99); setRegionId(administrationAreaId); } }, new IntentFilter(SyncAdministrationAreaService.TAG)); sharedPrefUtil = new SharedPrefUtil(this); setContentView(R.layout.activity_report); Toolbar myToolbar = findViewById(R.id.report_toolbar); setSupportActionBar(myToolbar); long areaId = sharedPrefUtil.getDefaultAdministrationAreaId(); if (areaId != -99) { setRegionId(areaId); } formView = findViewById(R.id.form); locationView = findViewById(R.id.location); textProgressLocationView = findViewById(R.id.progress_location_text); textProgressLocationView.setTypeface(StyleUtil.getDefaultTypeface(getAssets(), Typeface.NORMAL)); countdownTextView = findViewById(R.id.countdownTextView); countdownTextView.setTypeface(StyleUtil.getDefaultTypeface(getAssets(), Typeface.NORMAL)); refreshLocationButton = findViewById(R.id.refresh_location_button); refreshLocationButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { requestGPSLocation(); startLocationSearchTimeoutCountdown(); } }); progressBar = findViewById(R.id.progressBar); prevBtn = findViewById(R.id.prevBtn); nextBtn = findViewById(R.id.nextBtn); nextBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { nextScreen(); } }); nextBtn.setTypeface(StyleUtil.getDefaultTypeface(getAssets(), Typeface.NORMAL)); prevBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { onBackPressed(); } }); prevBtn.setTypeface(StyleUtil.getDefaultTypeface(getAssets(), Typeface.NORMAL)); disableMaskView = findViewById(R.id.disableMask); reportDataSource = new ReportDataSource(this); reportTypeDataSource = new ReportTypeDataSource(this); reportQueueDataSource = new ReportQueueDataSource(this); recordSpecDataSource = RecordSpecDataSource.Companion.getInstance(this); followAlertDataSource = new FollowAlertDataSource(this); if (savedInstanceState != null) { currentFragment = savedInstanceState.getString("currentFragment"); reportId = savedInstanceState.getLong("reportId"); reportType = savedInstanceState.getLong("reportType"); follow = savedInstanceState.getBoolean("follow"); testReport = savedInstanceState.getBoolean("testReport"); formIterator = (FormIterator) savedInstanceState.getSerializable("formIterator"); if (formIterator != null) { trigger = formIterator.getForm().getTrigger(); } reportSubmit = savedInstanceState.getInt("reportSubmit"); followActionName = savedInstanceState.getString("followActionName"); Log.d(TAG, "onCreate from savedInstance, testFlag = " + testReport); currentLatitude = savedInstanceState.getDouble("currentLatitude"); currentLongitude = savedInstanceState.getDouble("currentLongitude"); recordSpec = (RecordSpec) savedInstanceState.get("recordSpec"); parentReportGuid = savedInstanceState.getString("parentReportGuid"); } else { Intent intent = getIntent(); String action = intent.getAction(); int startPageId = -1; switch (action) { case ACTION_NEW_REPORT: reportType = intent.getLongExtra("reportType", 0); testReport = intent.getBooleanExtra("test", false); reportId = reportDataSource.createDraftReport(reportType, testReport); follow = false; break; case FollowAlertService.ORG_CM_PODD_REPORT_FOLLOW: reportType = intent.getLongExtra("reportType", 0); testReport = false; reportId = intent.getLongExtra("reportId", -99); follow = intent.getBooleanExtra("follow", false); break; case ACTION_FOR_EDIT_OR_VIEW: reportType = intent.getLongExtra("reportType", 0); testReport = intent.getBooleanExtra("test", false); reportId = intent.getLongExtra("reportId", -99); break; case ACTION_CREATE_FOLLOW_REPORT: reportType = intent.getLongExtra("reportType", 0); parentReportId = intent.getLongExtra("reportId", -99); reportId = reportDataSource.createFollowReport(parentReportId); follow = true; followActionName = "follow"; break; case ACTION_CREATE_FOLLOW_REPORT_WITH_ACTION: reportType = intent.getLongExtra("reportType", 0); parentReportId = intent.getLongExtra("reportId", -99); reportId = reportDataSource.createFollowReport(parentReportId); follow = true; followActionName = intent.getStringExtra("followActionName"); startPageId = intent.getIntExtra("startPageId", -1); break; case ACTION_CREATE_FOLLOW_REPORT_FROM_RECORD: reportType = intent.getLongExtra("reportType", 0); parentReportGuid = intent.getStringExtra("parentReportGuid"); String preloadFormData = intent.getStringExtra("preloadFormData"); reportId = reportDataSource.createFollowReport(reportType, parentReportGuid, preloadFormData); follow = true; break; } Form form = reportTypeDataSource.getForm(reportType); trigger = form.getTrigger(); if (trigger != null) { Log.d(TAG, String.format( "This report type contain a trigger with pattern:%s, pageId:%d, notificationText:%s", trigger.getPattern(), trigger.getPageId(), trigger.getNotificationText())); } if (intent.getAction() != null && intent.getAction().equals(FollowAlertService.ORG_CM_PODD_REPORT_FOLLOW)) { form.setStartWithTrigger(true); } if (startPageId != -1) { form.setStartPageId(startPageId); } formIterator = new FormIterator(form); Report report = loadFormData(form); recordSpec = recordSpecDataSource.getByReportTypeId(report.getType()); nextScreen(); } if (recordSpec != null) { final FirebaseContext firebaseContext = FirebaseContext.Companion .getInstance(PreferenceContext.Companion.getInstance(getApplicationContext())); firebaseContext.auth(this, new Function1<Boolean, Unit>() { @Override public Unit invoke(Boolean success) { if (success) { recordDataSource = firebaseContext.recordDataSource(recordSpec, parentReportGuid); } return null; } }); } // open location service only when // 1. Create a New report // 2. Edit a draft report which don't have any location attach. if ((reportSubmit == 0) && (currentLatitude == 0.00)) { buildGoogleApiClient(); if (formIterator.getForm().isForceLocation()) { switchToProgressLocationMode(); } } /* check softkeyboard visibility */ final View rootView = getWindow().getDecorView().findViewById(android.R.id.content); rootView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { // different devices' screens have normal height diff differently // eg, roughly 5.5" xxhdpi has 220px, 4.5" xhdpi has 110px, 4", 3.5" hdpi has 75px int heightDiff = rootView.getRootView().getHeight() - rootView.getHeight(); int limitHeightPx = (int) (getResources().getDisplayMetrics().density * 100); Log.d(TAG, String.format("diff height=%d, limit height=%d", heightDiff, limitHeightPx)); } }); Tracker tracker = ((PoddApplication) getApplication()).getTracker(PoddApplication.TrackerName.APP_TRACKER); tracker.setScreenName("Report-" + reportType); tracker.send(new HitBuilders.AppViewBuilder().build()); startTime = System.currentTimeMillis(); }
From source file:org.getlantern.firetweet.fragment.support.UserListFragment.java
@Override public void onActivityResult(final int requestCode, final int resultCode, final Intent data) { switch (requestCode) { case REQUEST_SELECT_USER: { if (resultCode != Activity.RESULT_OK || !data.hasExtra(EXTRA_USER) || mTwitterWrapper == null || mUserList == null)// w ww . j av a 2s . co m return; final ParcelableUser user = data.getParcelableExtra(EXTRA_USER); mTwitterWrapper.addUserListMembersAsync(mUserList.account_id, mUserList.id, user); return; } case REQUEST_SELECT_ACCOUNT: { final ParcelableUserList userList = mUserList; if (userList == null) return; if (resultCode == Activity.RESULT_OK) { if (data == null || !data.hasExtra(EXTRA_ID)) return; final long accountId = data.getLongExtra(EXTRA_ID, -1); openUserListDetails(getActivity(), accountId, userList.id, userList.user_id, userList.user_screen_name, userList.name); } break; } } super.onActivityResult(requestCode, resultCode, data); }
From source file:com.tingtingapps.securesms.ConversationActivity.java
private void initializeReceivers() { securityUpdateReceiver = new BroadcastReceiver() { @Override/*from w ww. j a v a2 s . c o m*/ public void onReceive(Context context, Intent intent) { long eventThreadId = intent.getLongExtra("thread_id", -1); if (eventThreadId == threadId || eventThreadId == -2) { initializeSecurity(); calculateCharactersRemaining(); } } }; groupUpdateReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { Log.w("ConversationActivity", "Group update received..."); if (recipients != null) { long[] ids = recipients.getIds(); Log.w("ConversationActivity", "Looking up new recipients..."); recipients = RecipientFactory.getRecipientsForIds(context, ids, false); titleView.setTitle(recipients); } } }; registerReceiver(securityUpdateReceiver, new IntentFilter(SecurityEvent.SECURITY_UPDATE_EVENT), KeyCachingService.KEY_PERMISSION, null); registerReceiver(groupUpdateReceiver, new IntentFilter(GroupDatabase.DATABASE_UPDATE_ACTION)); }
From source file:com.trimble.mcs.cordova.plugin.TrmbMcsRfid.java
public void handleRfidTagIntent(Context context, Intent intent) { CallbackContext cb = mScanTagCallback; if (cb == null) return;//from w ww . java 2s . com String action = intent.getAction(); if (action.equals(RfidConstants.ACTION_RFID_TAG_SCANNED)) { // Extract tag data from intent String tagID = intent.getStringExtra(RfidConstants.RFID_FIELD_ID); String memory = intent.getStringExtra(RfidConstants.RFID_FIELD_MEMORY); String tagType = intent.getStringExtra(RfidConstants.RFID_FIELD_TAG_TYPE); int rssi = intent.getIntExtra(RfidConstants.RFID_FIELD_RSSI, 0); int readCount = intent.getIntExtra(RfidConstants.RFID_FIELD_READ_COUNT, 0); long timeStamp = intent.getLongExtra(RfidConstants.RFID_FIELD_TIME_STAMP, 0); // Store tag data in a JSON object for transmission to javascript JSONObject tagInfo = new JSONObject(); try { if (tagID != null) tagInfo.put("tagID", tagID); if (memory != null) tagInfo.put("memory", memory); if (tagType != null) tagInfo.put("tagType", tagType); if (rssi != 0) tagInfo.put("rssi", rssi); if (readCount != 0) tagInfo.put("readCount", readCount); if (timeStamp != 0) tagInfo.put("timeStamp", timeStamp); } catch (JSONException e) { Log.d(TAG, "Error populating JSON object with scan data: " + e.getMessage()); } PluginResult result = new PluginResult(PluginResult.Status.OK, tagInfo); result.setKeepCallback(true); cb.sendPluginResult(result); } }
From source file:com.hippo.ehviewer.download.DownloadService.java
private void handleIntent(Intent intent) { String action = null;// w w w . j a va2s . c o m if (intent != null) { action = intent.getAction(); } if (ACTION_START.equals(action)) { GalleryInfo gi = intent.getParcelableExtra(KEY_GALLERY_INFO); String label = intent.getStringExtra(KEY_LABEL); if (gi != null && mDownloadManager != null) { mDownloadManager.startDownload(gi, label); } } else if (ACTION_START_RANGE.equals(action)) { LongList gidList = intent.getParcelableExtra(KEY_GID_LIST); if (gidList != null && mDownloadManager != null) { mDownloadManager.startRangeDownload(gidList); } } else if (ACTION_START_ALL.equals(action)) { if (mDownloadManager != null) { mDownloadManager.startAllDownload(); } } else if (ACTION_STOP.equals(action)) { long gid = intent.getLongExtra(KEY_GID, -1); if (gid != -1 && mDownloadManager != null) { mDownloadManager.stopDownload(gid); } } else if (ACTION_STOP_CURRENT.equals(action)) { if (mDownloadManager != null) { mDownloadManager.stopCurrentDownload(); } } else if (ACTION_STOP_RANGE.equals(action)) { LongList gidList = intent.getParcelableExtra(KEY_GID_LIST); if (gidList != null && mDownloadManager != null) { mDownloadManager.stopRangeDownload(gidList); } } else if (ACTION_STOP_ALL.equals(action)) { if (mDownloadManager != null) { mDownloadManager.stopAllDownload(); } } else if (ACTION_DELETE.equals(action)) { long gid = intent.getLongExtra(KEY_GID, -1); if (gid != -1 && mDownloadManager != null) { mDownloadManager.deleteDownload(gid); } } else if (ACTION_DELETE_RANGE.equals(action)) { LongList gidList = intent.getParcelableExtra(KEY_GID_LIST); if (gidList != null && mDownloadManager != null) { mDownloadManager.deleteRangeDownload(gidList); } } else if (ACTION_CLEAR.equals(action)) { clear(); } checkStopSelf(); }
From source file:com.nachiket.titan.LibraryActivity.java
/** * Builds a media query based off the data stored in the given intent. * * @param intent An intent created with/* w w w. ja va2 s . c om*/ * {@link LibraryAdapter#createData(View)}. * @param empty If true, use the empty projection (only query id). * @param all If true query all songs in the adapter; otherwise query based * on the row selected. */ private QueryTask buildQueryFromIntent(Intent intent, boolean empty, boolean all) { int type = intent.getIntExtra("type", MediaUtils.TYPE_INVALID); String[] projection; if (type == MediaUtils.TYPE_PLAYLIST) projection = empty ? Song.EMPTY_PLAYLIST_PROJECTION : Song.FILLED_PLAYLIST_PROJECTION; else projection = empty ? Song.EMPTY_PROJECTION : Song.FILLED_PROJECTION; long id = intent.getLongExtra("id", LibraryAdapter.INVALID_ID); QueryTask query; if (type == MediaUtils.TYPE_FILE) { query = MediaUtils.buildFileQuery(intent.getStringExtra("file"), projection); } else if (all || id == LibraryAdapter.HEADER_ID) { query = ((MediaAdapter) mPagerAdapter.mAdapters[type]).buildSongQuery(projection); query.data = id; } else { query = MediaUtils.buildQuery(type, id, projection, null); } return query; }