List of usage examples for android.content Intent getLongExtra
public long getLongExtra(String name, long defaultValue)
From source file:com.android.transmart.services.PlaceCheckinService.java
/** * {@inheritDoc}//w w w . ja v a 2 s. c o m * Perform a checkin the specified venue. If the checkin fails, add it to the queue and * set an alarm to retry. * * Query the checkin queue to see if there are pending checkins to be retried. */ @Override protected void onHandleIntent(Intent intent) { // Retrieve the details for the checkin to perform. String reference = intent.getStringExtra(LocationConstants.EXTRA_KEY_REFERENCE); String id = intent.getStringExtra(LocationConstants.EXTRA_KEY_ID); long timeStamp = intent.getLongExtra(LocationConstants.EXTRA_KEY_TIME_STAMP, 0); // Check if we're running in the foreground, if not, check if // we have permission to do background updates. boolean backgroundAllowed = cm.getBackgroundDataSetting(); boolean inBackground = sharedPreferences.getBoolean(LocationConstants.EXTRA_KEY_IN_BACKGROUND, true); if (reference != null && !backgroundAllowed && inBackground) { addToQueue(timeStamp, reference, id); return; } // Check to see if we are connected to a data network. NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); boolean isConnected = activeNetwork != null && activeNetwork.isConnectedOrConnecting(); // If we're not connected then disable the retry Alarm, enable the Connectivity Changed Receiver // and add the new checkin directly to the queue. The Connectivity Changed Receiver will listen // for when we connect to a network and start this service to retry the checkins. if (!isConnected) { // No connection so no point triggering an alarm to retry until we're connected. alarmManager.cancel(retryQueuedCheckinsPendingIntent); // Enable the Connectivity Changed Receiver to listen for connection to a network // so we can commit the pending checkins. PackageManager pm = getPackageManager(); ComponentName connectivityReceiver = new ComponentName(this, ConnectivityChangedReceiver.class); pm.setComponentEnabledSetting(connectivityReceiver, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP); // Add this checkin to the queue. addToQueue(timeStamp, reference, id); } else { // Execute the checkin. If it fails, add it to the retry queue. if (reference != null) { if (!checkin(timeStamp, reference, id)) addToQueue(timeStamp, reference, id); } // Retry the queued checkins. ArrayList<String> successfulCheckins = new ArrayList<String>(); Cursor queuedCheckins = contentResolver.query(QueuedCheckinsContentProvider.CONTENT_URI, null, null, null, null); try { // Retry each checkin. while (queuedCheckins.moveToNext()) { long queuedTimeStamp = queuedCheckins .getLong(queuedCheckins.getColumnIndex(QueuedCheckinsContentProvider.KEY_TIME_STAMP)); String queuedReference = queuedCheckins .getString(queuedCheckins.getColumnIndex(QueuedCheckinsContentProvider.KEY_REFERENCE)); String queuedId = queuedCheckins .getString(queuedCheckins.getColumnIndex(QueuedCheckinsContentProvider.KEY_ID)); if (queuedReference == null || checkin(queuedTimeStamp, queuedReference, queuedId)) successfulCheckins.add(queuedReference); } // Delete the queued checkins that were successful. if (successfulCheckins.size() > 0) { StringBuilder sb = new StringBuilder("(" + QueuedCheckinsContentProvider.KEY_REFERENCE + "='" + successfulCheckins.get(0) + "'"); for (int i = 1; i < successfulCheckins.size(); i++) sb.append(" OR " + QueuedCheckinsContentProvider.KEY_REFERENCE + " = '" + successfulCheckins.get(i) + "'"); sb.append(")"); int deleteCount = contentResolver.delete(QueuedCheckinsContentProvider.CONTENT_URI, sb.toString(), null); Log.d(TAG, "Deleted: " + deleteCount); } // If there are still queued checkins then set a non-waking alarm to retry them. queuedCheckins.requery(); if (queuedCheckins.getCount() > 0) { long triggerAtTime = System.currentTimeMillis() + LocationConstants.CHECKIN_RETRY_INTERVAL; alarmManager.set(AlarmManager.ELAPSED_REALTIME, triggerAtTime, retryQueuedCheckinsPendingIntent); } else alarmManager.cancel(retryQueuedCheckinsPendingIntent); } finally { queuedCheckins.close(); } } }
From source file:ru.orangesoftware.financisto.activity.CategorySelector.java
public void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == Activity.RESULT_OK) { switch (requestCode) { case R.id.category_add: { categoryCursor.requery();//from w w w. j ava 2 s . c om long categoryId = data.getLongExtra(DatabaseHelper.CategoryColumns._id.name(), -1); if (categoryId != -1) { selectCategory(categoryId); } break; } case R.id.category_pick: { long categoryId = data.getLongExtra(CategorySelectorActivity.SELECTED_CATEGORY_ID, 0); selectCategory(categoryId); break; } } } }
From source file:me.futuretechnology.blops.ui.NewsInfoActivity.java
@Override protected void initUI() { super.initUI(); Intent intent = getIntent(); StringBuilder txtCaption = new StringBuilder(128); String author = intent.getStringExtra(EXTRA_AUTHOR); if (!TextUtils.isEmpty(author)) { txtCaption.append(author);/* w w w .ja va2 s.c o m*/ txtCaption.append('\n'); } txtCaption.append(DateTime.formatDateTime(this, intent.getLongExtra(EXTRA_DATE, 0), ", ")); TextView tvDate = (TextView) findViewById(R.id.news_caption); tvDate.setText(txtCaption); TextView tvTitle = (TextView) findViewById(R.id.news_title); tvTitle.setText(intent.getStringExtra(EXTRA_TITLE)); TextView tvContent = (TextView) findViewById(R.id.news_content); String txt = intent.getStringExtra(EXTRA_CONTENT_VALUES); tvContent.setText(Html.fromHtml(txt, null, new HtmlTagHandler())); // tvContent.setText(Html.fromHtml("Hello <b>world</b>!<br>This is only a <a href=\"http://www.google.com\">test</a>.")); tvContent.setMovementMethod(LinkMovementMethod.getInstance()); // Log.i("BLOPS", "types: ", intent.getStringExtra(EXTRA_CONTENT_TYPES)); Log.i("BLOPS", "values: ", txt); // Log.i("BLOPS", "url: ", intent.getStringExtra(EXTRA_URL)); // Log.i("BLOPS", "id: ", intent.getStringExtra(EXTRA_ID)); final String url = getIntent().getStringExtra(EXTRA_URL); FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab_open_in_browser); if (TextUtils.isEmpty(url)) { fab.setVisibility(View.GONE); } else { fab.setVisibility(View.VISIBLE); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent iBrowser = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); iBrowser.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(iBrowser); } }); fab.attachToScrollView((ObservableScrollView) findViewById(R.id.news_container)); } }
From source file:ro.edi.novelty.ui.NewsInfoActivity.java
@Override protected void initUI() { super.initUI(); Intent intent = getIntent(); StringBuilder txtCaption = new StringBuilder(128); String author = intent.getStringExtra(EXTRA_AUTHOR); if (!TextUtils.isEmpty(author)) { txtCaption.append(author);/*from w w w . j a v a 2s .c om*/ txtCaption.append('\n'); } txtCaption.append(DateTime.formatDateTime(this, intent.getLongExtra(EXTRA_DATE, 0), ", ")); TextView tvDate = (TextView) findViewById(R.id.news_caption); tvDate.setText(txtCaption); TextView tvTitle = (TextView) findViewById(R.id.news_title); tvTitle.setText(intent.getStringExtra(EXTRA_TITLE)); TextView tvContent = (TextView) findViewById(R.id.news_content); String txt = intent.getStringExtra(EXTRA_CONTENT_VALUES); tvContent.setText(Html.fromHtml(txt, null, new HtmlTagHandler())); // tvContent.setText(Html.fromHtml("Hello <b>world</b>!<br>This is only a <a href=\"http://www.google.com\">test</a>.")); tvContent.setMovementMethod(LinkMovementMethod.getInstance()); // Log.i("NOVELTY", "types: ", intent.getStringExtra(EXTRA_CONTENT_TYPES)); Log.i("NOVELTY", "values: ", txt); // Log.i("NOVELTY", "url: ", intent.getStringExtra(EXTRA_URL)); // Log.i("NOVELTY", "id: ", intent.getStringExtra(EXTRA_ID)); final String url = getIntent().getStringExtra(EXTRA_URL); FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab_open_in_browser); if (TextUtils.isEmpty(url)) { fab.setVisibility(View.GONE); } else { fab.setVisibility(View.VISIBLE); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent iBrowser = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); iBrowser.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(iBrowser); } }); fab.attachToScrollView((ObservableScrollView) findViewById(R.id.news_container)); } }
From source file:org.klnusbaum.udj.network.EventCommService.java
private void setEventData(Intent intent, AccountManager am, Account account) { am.setUserData(account, Constants.EVENT_NAME_DATA, intent.getStringExtra(Constants.EVENT_NAME_EXTRA)); am.setUserData(account, Constants.EVENT_HOSTNAME_DATA, intent.getStringExtra(Constants.EVENT_HOSTNAME_EXTRA)); am.setUserData(account, Constants.EVENT_HOST_ID_DATA, String.valueOf(intent.getLongExtra(Constants.EVENT_HOST_ID_EXTRA, -1))); am.setUserData(account, Constants.EVENT_LAT_DATA, String.valueOf(intent.getDoubleExtra(Constants.EVENT_LAT_EXTRA, -100.0))); am.setUserData(account, Constants.EVENT_LONG_DATA, String.valueOf(intent.getDoubleExtra(Constants.EVENT_LONG_EXTRA, -100.0))); }
From source file:de.azapps.mirakel.reminders.ReminderAlarm.java
@Override public void onReceive(final Context context, final Intent intent) { if (UPDATE_NOTIFICATION.equals(intent.getAction())) { NotificationService.updateServices(context); }// ww w . ja v a 2s.c o m if (!SHOW_TASK.equals(intent.getAction())) { return; } final long taskId = intent.getLongExtra(EXTRA_ID, 0); if (taskId == 0) { return; } final Optional<Task> task = Task.get(taskId); if (!task.isPresent()) { final PendingIntent pd = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); alarmManager.cancel(pd); ErrorReporter.report(ErrorType.TASK_VANISHED); } else { createNotification(context, task.get()); } }
From source file:com.flowzr.activity.BlotterFragment.java
public void createTransactionFromTemplate(Intent data) { long templateId = data.getLongExtra(SelectTemplateActivity.TEMPATE_ID, -1); int multiplier = data.getIntExtra(SelectTemplateActivity.MULTIPLIER, 1); boolean edit = data.getBooleanExtra(SelectTemplateActivity.EDIT_AFTER_CREATION, false); if (templateId > 0) { long id = duplicateTransaction(templateId, multiplier); Transaction t = db.getTransaction(id); if (t.fromAmount == 0 || edit) { new BlotterOperations(this, db, id).asNewFromTemplate().editTransaction(); }/*from w ww .j ava 2 s . c o m*/ } }
From source file:com.anrlabs.locationreminder.GeoFenceReceiver.java
@Override public void onReceive(Context context, Intent intent) { this.context = context; if (intent.getAction().equals("com.anrlabs.ACTION_RECEIVE_GEOFENCE")) { // if (intent instanceof ) broadcastIntent.addCategory(GeoFenceConsants.CATEGORY_LOCATION_SERVICES); handleEnter(intent);//from w ww .ja va 2s . c om } else if (intent.getAction().equals("android.intent.action.RUN")) { //call timer dataID = intent.getLongExtra("idNumber", -1); if (dataID > (-1)) { Cursor constantsCursor = DatabaseHelper.getInstance(context).loadReminderDetails(dataID); constantsCursor.move(1); strinIds = new String[] { Long.toString(dataID) }; sendNotification(constantsCursor.getString(constantsCursor.getColumnIndex(DatabaseHelper.TITLE))); constantsCursor.close(); } } }
From source file:de.vanita5.twittnuker.activity.support.QuickSearchBarActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_quick_search_bar); final List<ParcelableAccount> accounts = ParcelableAccount.getAccountsList(this, false); final AccountsSpinnerAdapter accountsSpinnerAdapter = new AccountsSpinnerAdapter(this, R.layout.spinner_item_account_icon); accountsSpinnerAdapter.setDropDownViewResource(R.layout.list_item_user); accountsSpinnerAdapter.addAll(accounts); mAccountSpinner.setAdapter(accountsSpinnerAdapter); mAccountSpinner.setOnItemSelectedListener(this); if (savedInstanceState == null) { final Intent intent = getIntent(); final int index = accountsSpinnerAdapter.findItemPosition(intent.getLongExtra(EXTRA_ACCOUNT_ID, -1)); if (index != -1) { mAccountSpinner.setSelection(index); }/* w w w .j a v a 2 s. c o m*/ } mUsersSearchAdapter = new SuggestionsAdapter(this); mSuggestionsList.setAdapter(mUsersSearchAdapter); mSuggestionsList.setOnItemClickListener(this); mSearchSubmit.setOnClickListener(this); mSearchQuery.setOnEditorActionListener(this); mSearchQuery.addTextChangedListener(this); getSupportLoaderManager().initLoader(0, null, this); }
From source file:com.google.firebase.quickstart.firebasestorage.java.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Initialize Firebase Auth mAuth = FirebaseAuth.getInstance();//from w w w .ja v a 2 s . c om // Click listeners findViewById(R.id.buttonCamera).setOnClickListener(this); findViewById(R.id.buttonSignIn).setOnClickListener(this); findViewById(R.id.buttonDownload).setOnClickListener(this); // Restore instance state if (savedInstanceState != null) { mFileUri = savedInstanceState.getParcelable(KEY_FILE_URI); mDownloadUrl = savedInstanceState.getParcelable(KEY_DOWNLOAD_URL); } onNewIntent(getIntent()); // Local broadcast receiver mBroadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { Log.d(TAG, "onReceive:" + intent); hideProgressDialog(); switch (intent.getAction()) { case MyDownloadService.DOWNLOAD_COMPLETED: // Get number of bytes downloaded long numBytes = intent.getLongExtra(MyDownloadService.EXTRA_BYTES_DOWNLOADED, 0); // Alert success showMessageDialog(getString(R.string.success), String.format(Locale.getDefault(), "%d bytes downloaded from %s", numBytes, intent.getStringExtra(MyDownloadService.EXTRA_DOWNLOAD_PATH))); break; case MyDownloadService.DOWNLOAD_ERROR: // Alert failure showMessageDialog("Error", String.format(Locale.getDefault(), "Failed to download from %s", intent.getStringExtra(MyDownloadService.EXTRA_DOWNLOAD_PATH))); break; case MyUploadService.UPLOAD_COMPLETED: case MyUploadService.UPLOAD_ERROR: onUploadResultIntent(intent); break; } } }; }