List of usage examples for android.content Intent getLongExtra
public long getLongExtra(String name, long defaultValue)
From source file:it.sineo.android.tileMapEditor.HomeActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == C.REQ_CODE_NEW_MAP) { if (resultCode == RESULT_OK && data != null) { String mapJSON = data.getStringExtra(C.EXTRA_MAP_JSON); TileMap map = new TileMap(mapJSON); ContentValues values = new ContentValues(); values.put(TileMap.Columns.KEY_NAME, map.name); values.put(TileMap.Columns.KEY_JSON_DATA, mapJSON); values.put(TileMap.Columns.KEY_THUMB, data.getByteArrayExtra(C.EXTRA_MAP_THUMB)); getContentResolver().insert(C.CONTENT_URI, values); }//from w ww .j ava 2s. c o m Log.d(TAG, "received code " + resultCode + " w/ data: " + data); } else if (requestCode == C.REQ_CODE_EDIT_MAP) { if (resultCode == RESULT_OK && data != null) { String mapJSON = data.getStringExtra(C.EXTRA_MAP_JSON); long id = data.getLongExtra(C.EXTRA_MAP_ID, -1); TileMap map = new TileMap(mapJSON); ContentValues values = new ContentValues(); values.put(TileMap.Columns.KEY_NAME, map.name); values.put(TileMap.Columns.KEY_JSON_DATA, mapJSON); values.put(TileMap.Columns.KEY_THUMB, data.getByteArrayExtra(C.EXTRA_MAP_THUMB)); Uri mapUri = Uri.withAppendedPath(C.CONTENT_URI, Long.toString(id)); getContentResolver().update(mapUri, values, null, null); } } super.onActivityResult(requestCode, resultCode, data); }
From source file:com.nachiket.titan.LibraryActivity.java
@Override public boolean handleMessage(Message message) { switch (message.what) { case MSG_ADD_TO_PLAYLIST: { Intent intent = (Intent) message.obj; addToPlaylist(intent.getLongExtra("playlist", -1), intent); break;/*from w w w. j av a 2s .c o m*/ } case MSG_NEW_PLAYLIST: { NewPlaylistDialog dialog = (NewPlaylistDialog) message.obj; if (dialog.isAccepted()) { String name = dialog.getText(); long playlistId = Playlist.createPlaylist(getContentResolver(), name); Intent intent = dialog.getIntent(); intent.putExtra("playlistName", name); addToPlaylist(playlistId, intent); } break; } case MSG_DELETE: delete((Intent) message.obj); break; case MSG_RENAME_PLAYLIST: { NewPlaylistDialog dialog = (NewPlaylistDialog) message.obj; if (dialog.isAccepted()) { long playlistId = dialog.getIntent().getLongExtra("id", -1); Playlist.renamePlaylist(getContentResolver(), playlistId, dialog.getText()); } break; } case MSG_SAVE_PAGE: { SharedPreferences.Editor editor = PlaybackService.getSettings(this).edit(); editor.putInt("library_page", message.arg1); editor.commit(); break; } default: return super.handleMessage(message); } return true; }
From source file:com.abcvoipsip.ui.account.AccountsEditListFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == Activity.RESULT_OK && data != null && data.getExtras() != null) { if (requestCode == CHOOSE_WIZARD) { // Wizard has been choosen, now create an account String wizardId = data.getStringExtra(WizardUtils.ID); if (wizardId != null) { showDetails(SipProfile.INVALID_ID, wizardId); }// w ww .ja v a 2 s . c o m } else if (requestCode == CHANGE_WIZARD) { // Change wizard done for this account. String wizardId = data.getStringExtra(WizardUtils.ID); long accountId = data.getLongExtra(Intent.EXTRA_UID, SipProfile.INVALID_ID); if (wizardId != null && accountId != SipProfile.INVALID_ID) { ContentValues cv = new ContentValues(); cv.put(SipProfile.FIELD_WIZARD, wizardId); getActivity().getContentResolver().update( ContentUris.withAppendedId(SipProfile.ACCOUNT_ID_URI_BASE, accountId), cv, null, null); } } } }
From source file:com.finchuk.clock2.MainActivity.java
/** * Handles a PendingIntent, fired from e.g. clicking a notification, that tells us to * set the ViewPager's current item and scroll to a specific RecyclerView item * given by its stable ID.//ww w . jav a2 s. c o m * * @param performScroll Whether to actually scroll to the stable id, if there is one. * Pass true if you know {@link * RecyclerViewFragment#onLoadFinished(Loader, BaseItemCursor) onLoadFinished()} * had previously been called. Otherwise, pass false so that we can * {@link RecyclerViewFragment#setScrollToStableId(long) setScrollToStableId(long)} * and let {@link * RecyclerViewFragment#onLoadFinished(Loader, BaseItemCursor) onLoadFinished()} * perform the scroll for us. */ private void handleActionScrollToStableId(@NonNull final Intent intent, final boolean performScroll) { if (ACTION_SCROLL_TO_STABLE_ID.equals(intent.getAction())) { final int targetPage = intent.getIntExtra(EXTRA_SHOW_PAGE, -1); if (targetPage >= 0 && targetPage <= mSectionsPagerAdapter.getCount() - 1) { // #post() works for any state the app is in, especially robust against // cases when the app was not previously in memory--i.e. this got called // in onCreate(). mViewPager.post(new Runnable() { @Override public void run() { mViewPager.setCurrentItem(targetPage, true/*smoothScroll*/); final long stableId = intent.getLongExtra(EXTRA_SCROLL_TO_STABLE_ID, -1); if (stableId != -1) { RecyclerViewFragment rvFrag = (RecyclerViewFragment) mSectionsPagerAdapter .getFragment(targetPage); if (performScroll) { rvFrag.performScrollToStableId(stableId); } else { rvFrag.setScrollToStableId(stableId); } } intent.setAction(null); intent.removeExtra(EXTRA_SHOW_PAGE); intent.removeExtra(EXTRA_SCROLL_TO_STABLE_ID); } }); } } }
From source file:com.nachiket.titan.LibraryActivity.java
/** * "Expand" the view represented by the given intent by setting the limiter * from the view and switching to the appropriate tab. * * @param intent An intent created with/*from w w w . jav a2s . c om*/ * {@link LibraryAdapter#createData(View)}. */ private void expand(Intent intent) { int type = intent.getIntExtra("type", MediaUtils.TYPE_INVALID); long id = intent.getLongExtra("id", LibraryAdapter.INVALID_ID); int tab = mPagerAdapter.setLimiter(mPagerAdapter.mAdapters[type].buildLimiter(id)); if (tab == -1 || tab == mViewPager.getCurrentItem()) updateLimiterViews(); else mViewPager.setCurrentItem(tab); }
From source file:com.partypoker.poker.engagement.reach.EngagementReachAgent.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 w w w. j av a 2s . c o m public <T extends EngagementReachContent> T getContent(Intent intent) { return getContent(intent.getLongExtra(INTENT_EXTRA_CONTENT_ID, 0)); }
From source file:com.nachiket.titan.LibraryActivity.java
/** * Delete the media represented by the given intent and show a Toast * informing the user of this./*from w w w. j a v a 2s.c om*/ * * @param intent An intent created with * {@link LibraryAdapter#createData(View)}. */ private void delete(Intent intent) { int type = intent.getIntExtra("type", MediaUtils.TYPE_INVALID); long id = intent.getLongExtra("id", LibraryAdapter.INVALID_ID); String message = null; Resources res = getResources(); if (type == MediaUtils.TYPE_FILE) { String file = intent.getStringExtra("file"); boolean success = MediaUtils.deleteFile(new File(file)); if (!success) { message = res.getString(R.string.delete_file_failed, file); } } else if (type == MediaUtils.TYPE_PLAYLIST) { Playlist.deletePlaylist(getContentResolver(), id); } else { int count = PlaybackService.get(this).deleteMedia(type, id); message = res.getQuantityString(R.plurals.deleted, count, count); } if (message == null) { message = res.getString(R.string.deleted, intent.getStringExtra("title")); } Toast.makeText(this, message, Toast.LENGTH_SHORT).show(); }
From source file:com.sharky.BillingService.java
public void handleCommand(Intent intent, int startId) { String action = intent.getAction(); if (Consts.ACTION_CONFIRM_NOTIFICATION.equals(action)) { String[] notifyIds = intent.getStringArrayExtra(Consts.NOTIFICATION_ID); confirmNotifications(startId, notifyIds); } else if (Consts.ACTION_GET_PURCHASE_INFORMATION.equals(action)) { String notifyId = intent.getStringExtra(Consts.NOTIFICATION_ID); getPurchaseInformation(startId, new String[] { notifyId }); } else if (Consts.ACTION_PURCHASE_STATE_CHANGED.equals(action)) { String signedData = intent.getStringExtra(Consts.INAPP_SIGNED_DATA); String signature = intent.getStringExtra(Consts.INAPP_SIGNATURE); purchaseStateChanged(startId, signedData, signature); } else if (Consts.ACTION_RESPONSE_CODE.equals(action)) { long requestId = intent.getLongExtra(Consts.INAPP_REQUEST_ID, -1); int responseCodeIndex = intent.getIntExtra(Consts.INAPP_RESPONSE_CODE, ResponseCode.RESULT_ERROR.ordinal()); ResponseCode responseCode = ResponseCode.valueOf(responseCodeIndex); checkResponseCode(requestId, responseCode); }//from ww w . j av a 2s. c o m }
From source file:de.quist.app.errorreporter.ExceptionReportService.java
private void sendReport(Intent intent) throws UnsupportedEncodingException, NameNotFoundException { Log.v(TAG, "Got request to report error: " + intent.toString()); Uri server = getTargetUrl();// ww w . j a v a 2s . c o m boolean isManualReport = intent.getBooleanExtra(EXTRA_MANUAL_REPORT, false); boolean isReportOnFroyo = isReportOnFroyo(); boolean isFroyoOrAbove = isFroyoOrAbove(); if (isFroyoOrAbove && !isManualReport && !isReportOnFroyo) { // We don't send automatic reports on froyo or above Log.d(TAG, "Don't send automatic report on froyo"); return; } Set<String> fieldsToSend = getFieldsToSend(); String stacktrace = intent.getStringExtra(EXTRA_STACK_TRACE); String exception = intent.getStringExtra(EXTRA_EXCEPTION_CLASS); String message = intent.getStringExtra(EXTRA_MESSAGE); long availableMemory = intent.getLongExtra(EXTRA_AVAILABLE_MEMORY, -1l); long totalMemory = intent.getLongExtra(EXTRA_TOTAL_MEMORY, -1l); String dateTime = intent.getStringExtra(EXTRA_EXCEPTION_TIME); String threadName = intent.getStringExtra(EXTRA_THREAD_NAME); String extraMessage = intent.getStringExtra(EXTRA_EXTRA_MESSAGE); List<NameValuePair> params = new ArrayList<NameValuePair>(); addNameValuePair(params, fieldsToSend, "exStackTrace", stacktrace); addNameValuePair(params, fieldsToSend, "exClass", exception); addNameValuePair(params, fieldsToSend, "exDateTime", dateTime); addNameValuePair(params, fieldsToSend, "exMessage", message); addNameValuePair(params, fieldsToSend, "exThreadName", threadName); if (extraMessage != null) addNameValuePair(params, fieldsToSend, "extraMessage", extraMessage); if (availableMemory >= 0) addNameValuePair(params, fieldsToSend, "devAvailableMemory", availableMemory + ""); if (totalMemory >= 0) addNameValuePair(params, fieldsToSend, "devTotalMemory", totalMemory + ""); PackageManager pm = getPackageManager(); try { PackageInfo packageInfo = pm.getPackageInfo(getPackageName(), 0); addNameValuePair(params, fieldsToSend, "appVersionCode", packageInfo.versionCode + ""); addNameValuePair(params, fieldsToSend, "appVersionName", packageInfo.versionName); addNameValuePair(params, fieldsToSend, "appPackageName", packageInfo.packageName); } catch (NameNotFoundException e) { } addNameValuePair(params, fieldsToSend, "devModel", android.os.Build.MODEL); addNameValuePair(params, fieldsToSend, "devSdk", android.os.Build.VERSION.SDK); addNameValuePair(params, fieldsToSend, "devReleaseVersion", android.os.Build.VERSION.RELEASE); HttpClient httpClient = new DefaultHttpClient(); HttpPost post = new HttpPost(server.toString()); post.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8)); Log.d(TAG, "Created post request"); try { httpClient.execute(post); Log.v(TAG, "Reported error: " + intent.toString()); } catch (ClientProtocolException e) { // Ignore this kind of error Log.e(TAG, "Error while sending an error report", e); } catch (SSLException e) { Log.e(TAG, "Error while sending an error report", e); } catch (IOException e) { if (e instanceof SocketException && e.getMessage().contains("Permission denied")) { Log.e(TAG, "You don't have internet permission", e); } else { int maximumRetryCount = getMaximumRetryCount(); int maximumExponent = getMaximumBackoffExponent(); // Retry at a later point in time AlarmManager alarmMgr = (AlarmManager) getSystemService(ALARM_SERVICE); int exponent = intent.getIntExtra(EXTRA_CURRENT_RETRY_COUNT, 0); intent.putExtra(EXTRA_CURRENT_RETRY_COUNT, exponent + 1); PendingIntent operation = PendingIntent.getService(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); if (exponent >= maximumRetryCount) { // Discard error Log.w(TAG, "Error report reached the maximum retry count and will be discarded.\nStacktrace:\n" + stacktrace); return; } if (exponent > maximumExponent) { exponent = maximumExponent; } long backoff = (1 << exponent) * 1000; // backoff in ms alarmMgr.set(AlarmManager.ELAPSED_REALTIME, SystemClock.elapsedRealtime() + backoff, operation); } } }
From source file:com.ninetwozero.battlelog.fragments.ForumThreadFragment.java
public void openThread(Intent data) { if (textTitle == null) { storedRequest = data;/*from ww w. j a va 2s .c o m*/ } else { threadId = data.getLongExtra("threadId", 0); textTitle.setText(data.getStringExtra("threadTitle")); currentPage = data.getIntExtra("pageId", 1); reload(); } }