Example usage for android.content Intent getLongExtra

List of usage examples for android.content Intent getLongExtra

Introduction

In this page you can find the example usage for android.content Intent getLongExtra.

Prototype

public long getLongExtra(String name, long defaultValue) 

Source Link

Document

Retrieve extended data from the intent.

Usage

From source file:org.ewicom.pps.unitinfo.UnitDetails.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_details);

    final Intent intent = getIntent();
    unitID = intent.getLongExtra("unit_id", -1);

    unitDetailsPageAdapter = new UnitDetailsPageAdapter(getSupportFragmentManager(), unitID);
    viewPager = (ViewPager) findViewById(R.id.pager);
    viewPager.setOnPageChangeListener(new OnPageChangeListener() {

        @Override/*from  w  w w .j  a  va  2s  .  co  m*/
        public void onPageSelected(int position) {
            getSupportActionBar().setSelectedNavigationItem(position);
        }

        @Override
        public void onPageScrolled(int arg0, float arg1, int arg2) {
        }

        @Override
        public void onPageScrollStateChanged(int arg0) {
        }
    });
    viewPager.setAdapter(unitDetailsPageAdapter);

    final ActionBar actionBar = getSupportActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    actionBar.setDisplayHomeAsUpEnabled(true);

    actionBar.addTab(actionBar.newTab().setIcon(R.drawable.ic_collections_labels).setTabListener(this));
    actionBar.addTab(actionBar.newTab().setIcon(R.drawable.ic_social_group).setTabListener(this));
    actionBar.addTab(actionBar.newTab().setIcon(R.drawable.ic_device_access_end_call).setTabListener(this));
}

From source file:org.akvo.flow.service.SurveyedLocaleSyncService.java

@Override
protected void onHandleIntent(Intent intent) {
    final long surveyGroupId = intent.getLongExtra(SURVEY_GROUP, SurveyGroup.ID_NONE);
    int syncedRecords = 0;
    FlowApi api = new FlowApi();
    SurveyDbAdapter database = new SurveyDbAdapter(getApplicationContext()).open();
    displayNotification(getString(R.string.syncing_records), getString(R.string.pleasewait), false);
    try {/*w  w w .  ja  v a 2 s  . c o  m*/
        Set<String> batch, lastBatch = null;
        while (true) {
            batch = sync(database, api, surveyGroupId);
            if (lastBatch != null && lastBatch.containsAll(batch)) {
                break;
            }
            syncedRecords += batch.size();
            sendBroadcastNotification();// Keep the UI fresh!
            displayNotification(getString(R.string.syncing_records),
                    String.format(getString(R.string.synced_records), syncedRecords), false);
            lastBatch = batch;
        }
        displayNotification(getString(R.string.sync_finished),
                String.format(getString(R.string.synced_records), syncedRecords), true);
    } catch (IOException e) {
        Log.e(TAG, e.getMessage());
        displayToast(getString(R.string.network_error));
        displayNotification(getString(R.string.sync_error), getString(R.string.network_error), true);
    } catch (ApiException e) {
        Log.e(TAG, e.getMessage());
        String message = e.getMessage();
        switch (e.getStatus()) {
        case ApiException.Status.SC_FORBIDDEN:
            // A missing assignment might be the issue. Let's hint the user.
            message = getString(R.string.error_assignment_text);
            break;
        }
        displayToast(message);
        displayNotification(getString(R.string.sync_error), message, true);
    } finally {
        database.close();
    }

    sendBroadcastNotification();
}

From source file:co.nerdart.ourss.activity.EntriesListActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    UiUtils.setPreferenceTheme(this);
    super.onCreate(savedInstanceState);

    ActionBar actionBar = getActionBar();
    if (actionBar != null)
        actionBar.setDisplayHomeAsUpEnabled(true);

    Intent intent = getIntent();
    long feedId = intent.getLongExtra(FeedColumns._ID, 0);

    String title = null;//  w  w w.  j  av  a  2s.c  o  m
    if (feedId > 0) {
        Cursor cursor = getContentResolver().query(FeedColumns.CONTENT_URI(feedId), FEED_PROJECTION, null, null,
                null);

        if (cursor.moveToFirst()) {
            title = cursor.isNull(0) ? cursor.getString(1) : cursor.getString(0);
            iconBytes = cursor.getBlob(2);
        }
        cursor.close();
    }

    if (title != null) {
        setTitle(title);
    }

    if (savedInstanceState == null) {
        EntriesListFragment fragment = new EntriesListFragment();
        Bundle args = new Bundle();
        args.putParcelable(EntriesListFragment.ARG_URI, intent.getData());
        fragment.setArguments(args);
        fragment.setHasOptionsMenu(true);
        getSupportFragmentManager().beginTransaction().add(android.R.id.content, fragment, "fragment").commit();
    }

    if (iconBytes != null && iconBytes.length > 0) {
        int bitmapSizeInDip = UiUtils.dpToPixel(24);
        Bitmap bitmap = BitmapFactory.decodeByteArray(iconBytes, 0, iconBytes.length);
        if (bitmap != null) {
            if (bitmap.getHeight() != bitmapSizeInDip) {
                bitmap = Bitmap.createScaledBitmap(bitmap, bitmapSizeInDip, bitmapSizeInDip, false);
            }

            getActionBar().setIcon(new BitmapDrawable(getResources(), bitmap));
        }
    }

    if (MainActivity.mNotificationManager == null) {
        MainActivity.mNotificationManager = (NotificationManager) getSystemService(
                Context.NOTIFICATION_SERVICE);
    }
}

From source file:com.uiowa.chat.services.ReplyService.java

@Override
protected void onHandleIntent(Intent intent) {
    Bundle remoteInput = RemoteInput.getResultsFromIntent(intent);

    Sender s = new Sender(this);
    s.sendThreadedMessage(intent.getStringExtra(EXTRA_USERNAME), intent.getLongExtra(EXTRA_THREAD_ID, -1),
            new RegistrationUtils().getMyUserId(this),
            remoteInput.getCharSequence(EXTRA_VOICE_REPLY).toString());

    NotificationManagerCompat manager = NotificationManagerCompat.from(this);
    manager.cancel(PushNotificationService.MESSAGE_NOTIFICATION_ID);
}

From source file:cz.hnutiduha.bioadresar.detail.DetailActivity.java

/** Called when the activity is first created. */
@Override/*from  w  ww  . j  a  v  a 2s  .c o m*/
public void onCreate(Bundle savedInstanceState) {
    // NOTE: we do not support saved instance reload (needs farm packing)
    super.onCreate(null);

    Intent myIntent = getIntent();
    int sourceId = myIntent.getIntExtra(EXTRA_SOURCE, DataSourceFactory.SOURCE_INVALID);
    long locationId = myIntent.getLongExtra(EXTRA_ID, LocationInfo.INVALID_LOCATION_ID);

    DataSource source = DataSourceFactory.getDataSource(sourceId, this);
    if (source == null) {
        Log.e("view", "unknown source for location");
        return;
    }

    currentLocation = source.getLocation(locationId);
    if (currentLocation == null) {
        Log.e("view", "unknown location");
        return;
    }

    LinearLayout me = new LinearLayout(this);
    me.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,
            LinearLayout.LayoutParams.FILL_PARENT));
    me.setId(R.id.fragmentContainer);

    Fragment content = currentLocation.getDetailFragment(this);

    getSupportFragmentManager().beginTransaction().add(R.id.fragmentContainer, content).commit();

    this.setContentView(me);

    MenuHandler.installDropDown(getSupportActionBar(), this);
}

From source file:org.isoron.uhabits.HabitBroadcastReceiver.java

private boolean checkWeekday(Intent intent, Habit habit) {
    Long timestamp = intent.getLongExtra("timestamp", DateHelper.getStartOfToday());

    boolean reminderDays[] = DateHelper.unpackWeekdayList(habit.reminderDays);
    int weekday = DateHelper.getWeekday(timestamp);

    return reminderDays[weekday];
}

From source file:de.dreier.mytargets.features.scoreboard.ScoreboardActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    binding = DataBindingUtil.setContentView(this, R.layout.activity_scoreboard);

    Intent intent = getIntent();
    mTraining = intent.getLongExtra(TRAINING_ID, -1);
    mRound = intent.getLongExtra(ROUND_ID, -1);

    binding.webView.setWebViewClient(new WebViewClient() {
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            return false;
        }/*  w  w w  .  j  a v  a 2 s .  c o m*/

        @Override
        public void onPageFinished(WebView view, String url) {
            pageLoaded = true;
            supportInvalidateOptionsMenu();
        }
    });

    ToolbarUtils.showHomeAsUp(this);
}

From source file:ru.yandex.subtitles.service.speechkit.recognition.PhraseBroadcastReceiver.java

@Override
public void onReceive(final Context context, final Intent intent) {
    final String action = (intent != null ? intent.getAction() : null);
    if (ACTION_PHRASE_RECOGNIZED.equals(action)) {
        final long threadId = intent.getLongExtra(EXTRA_THREAD, -1);
        final String phrase = intent.getStringExtra(Intent.EXTRA_TEXT);
        if (mThreadId == threadId) {
            mOnPhraseRecognizedListener.onPhraseRecognized(phrase);
        }/*from  w ww  . j  av  a  2  s. co  m*/
    }
}

From source file:org.flerda.android.honeypad.NotepadActivity.java

private void viewNote(Intent launchIntent, NoteListFragment list) {
    final long noteId = launchIntent.getLongExtra(EXTRA_NOTE_ID, -1);
    showNote(ContentUris.withAppendedId(NotesProvider.CONTENT_URI, noteId));
    list.setActivatedNote(noteId);/*  w ww .j  a  v  a2  s.  com*/
}

From source file:com.ultramegasoft.flavordex2.AddEntryActivity.java

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    final ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
    }/*  w ww. jav a 2 s  .  c  om*/

    if (savedInstanceState == null) {
        final Intent intent = getIntent();
        final Bundle args = new Bundle();
        args.putLong(AddEntryFragment.ARG_CAT_ID, intent.getLongExtra(EXTRA_CAT_ID, 0));
        args.putString(AddEntryFragment.ARG_CAT_NAME, intent.getStringExtra(EXTRA_CAT_NAME));

        final Fragment fragment = new AddEntryFragment();
        fragment.setArguments(args);

        getSupportFragmentManager().beginTransaction().add(android.R.id.content, fragment).commit();
    }
}