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.deviceconnect.android.localoauth.fragment.ConfirmAuthFragment.java

@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
        final Bundle savedInstanceState) {

    Intent intent = getActivity().getIntent();
    if (intent == null) {
        getActivity().finish();//from  w w w .j  a  va 2  s .c o m
        return null;
    }
    mThreadId = intent.getLongExtra(ConfirmAuthActivity.EXTRA_THREAD_ID, -1);
    if (mThreadId == -1) {
        getActivity().finish();
        return null;
    }

    String applicationName = intent.getStringExtra(ConfirmAuthActivity.EXTRA_APPLICATION_NAME);
    String packageName = intent.getStringExtra(ConfirmAuthActivity.EXTRA_PACKAGE_NAME);
    String keyword = intent.getStringExtra(ConfirmAuthActivity.EXTRA_KEYWORD);
    String[] displayScopes = intent.getStringArrayExtra(ConfirmAuthActivity.EXTRA_DISPLAY_SCOPES);
    String expirePeriod = toStringExpiredPeriod();
    boolean isForPlugin = intent.getBooleanExtra(ConfirmAuthActivity.EXTRA_IS_FOR_DEVICEPLUGIN, true);
    boolean isAutoFlag = intent.getBooleanExtra(ConfirmAuthActivity.EXTRA_AUTO_FLAG, false);
    long requestTime = intent.getLongExtra(ConfirmAuthActivity.EXTRA_REQUEST_TIME, System.currentTimeMillis());
    long timeout = DEFAULT_TIMEOUT - (System.currentTimeMillis() - requestTime);

    int layoutId;
    if (isForPlugin) {
        layoutId = R.layout.confirm_auth_activity_plugin;
    } else {
        layoutId = R.layout.confirm_auth_activity_manager;
    }
    View view = inflater.inflate(layoutId, container, false);
    view.setFocusableInTouchMode(true);
    view.setOnKeyListener(new View.OnKeyListener() {
        @Override
        public boolean onKey(final View v, final int keyCode, final KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP) {
                notApprovalProc();
                return true;
            }
            return false;
        }
    });

    // ?
    TextView textViewExpirePeriod = (TextView) view.findViewById(R.id.textViewExpirePeriod);
    textViewExpirePeriod.setText(expirePeriod);

    // ??
    TextView textViewApplicationName = (TextView) view.findViewById(R.id.textViewAccessToken);
    textViewApplicationName.setText(applicationName);

    // 
    ListView listViewScopes = (ListView) view.findViewById(R.id.listViewScopes);
    listViewScopes.setAdapter(new ArrayAdapter<>(getActivity(), R.layout.confirm_auth_scopes_list_item,
            R.id.textViewScope, displayScopes));

    // ?
    Button buttonApproval = (Button) view.findViewById(R.id.buttonApproval);
    buttonApproval.setOnClickListener(mOnButtonApprovalClickListener);

    // ?
    Button buttonReject = (Button) view.findViewById(R.id.buttonReject);
    buttonReject.setOnClickListener(mOnButtonApprovalClickListener);

    if (!isForPlugin) {
        // ?(=?)???
        TextView textViewPackageName = (TextView) view.findViewById(R.id.textPackageName);
        textViewPackageName.setText(packageName);
        // 
        TextView textViewKeyword = (TextView) view.findViewById(R.id.textKeyword);
        textViewKeyword.setText(keyword);
    }

    if (timeout > 0) {
        startTimeoutTimer(timeout);
    } else {
        // ????????Activity?
        getActivity().finish();
    }

    if (isAutoFlag) {
        new Handler(Looper.getMainLooper()).post(new Runnable() {
            @Override
            public void run() {
                approvalProc();
            }
        });
    }

    return view;
}

From source file:com.conferenceengineer.android.iosched.service.SessionAlarmService.java

@Override
protected void onHandleIntent(Intent intent) {
    final String action = intent.getAction();
    if (ACTION_SCHEDULE_ALL_STARRED_BLOCKS.equals(action)) {
        scheduleAllStarredBlocks();/*from   w w w.ja  v  a 2s .com*/
        return;
    }

    final long sessionStart = intent.getLongExtra(SessionAlarmService.EXTRA_SESSION_START, UNDEFINED_VALUE);
    if (sessionStart == UNDEFINED_VALUE)
        return;

    final long sessionEnd = intent.getLongExtra(SessionAlarmService.EXTRA_SESSION_END, UNDEFINED_VALUE);
    if (sessionEnd == UNDEFINED_VALUE)
        return;

    final long sessionAlarmOffset = intent.getLongExtra(SessionAlarmService.EXTRA_SESSION_ALARM_OFFSET,
            UNDEFINED_ALARM_OFFSET);

    if (ACTION_NOTIFY_SESSION.equals(action)) {
        notifySession(sessionStart, sessionEnd, sessionAlarmOffset);
    } else if (ACTION_SCHEDULE_STARRED_BLOCK.equals(action)) {
        scheduleAlarm(sessionStart, sessionEnd, sessionAlarmOffset);
    }
}

From source file:net.kjmaster.cookiemom.MainActivity.java

@OnActivityResult(Constants.EAT_COOKIES)
void onEatSelectScoutResult(int resultCode, Intent data) {
    if (data != null) {
        long scoutId = data.getLongExtra("scout_id", 0);
        ScoutPickupActivity_.intent(this).ScoutId(scoutId).isEditable(true)
                .startForResult(Constants.SCOUT_REQUEST);
    }/*from w  ww  .j  av a2 s.c  om*/
}

From source file:cn.studyjams.s2.sj0132.bowenyan.mygirlfriend.nononsenseapps.notepad.ui.editor.ActivityEditor.java

long getNoteId(@NonNull final Intent intent) {
    long retval = -1;
    if (intent.getData() != null && (Intent.ACTION_EDIT.equals(intent.getAction())
            || Intent.ACTION_VIEW.equals(intent.getAction()))) {
        if (intent.getData().getPath().startsWith(TaskList.URI.getPath())) {
            // Find it in the extras. See DashClock extension for an example
            retval = intent.getLongExtra(Task.TABLE_NAME, -1);
        } else if ((intent.getData().getPath().startsWith(LegacyDBHelper.NotePad.Notes.PATH_VISIBLE_NOTES)
                || intent.getData().getPath().startsWith(LegacyDBHelper.NotePad.Notes.PATH_NOTES)
                || intent.getData().getPath().startsWith(Task.URI.getPath()))) {
            retval = Long.parseLong(intent.getData().getLastPathSegment());
        }/*from  w ww  .j  a  va2s . c o  m*/
    }
    return retval;
}

From source file:ivl.android.moneybalance.ExpenseListActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    supportRequestWindowFeature(WindowCompat.FEATURE_ACTION_BAR);

    setContentView(R.layout.expense_list);

    Intent intent = getIntent();
    calculationId = intent.getLongExtra(PARAM_CALCULATION_ID, -1);

    ExpandableListView listView = (ExpandableListView) findViewById(R.id.expense_list);
    adapter = new ExpenseAdapter(this);
    listView.setAdapter(adapter);//  w  w w .ja v a 2  s  .  co  m
    listView.setOnChildClickListener(this);
    registerForContextMenu(listView);
    setContentView(listView);

    refresh();
}

From source file:com.cyanogenmod.eleven.ui.activities.HomeActivity.java

private long parseIdFromIntent(Intent intent, String longKey, String stringKey, long defaultId) {
    long id = intent.getLongExtra(longKey, -1);
    if (id < 0) {
        String idString = intent.getStringExtra(stringKey);
        if (idString != null) {
            try {
                id = Long.parseLong(idString);
            } catch (NumberFormatException e) {
                Log.e(TAG, e.getMessage());
            }/*from   ww w . j a  va2 s . c o  m*/
        }
    }
    return id;
}

From source file:com.slx.funstream.ui.streams.StreamActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    AndroidInjection.inject(this);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.stream_layout);

    ButterKnife.bind(this);

    if (toolbar != null) {
        setSupportActionBar(toolbar);// ww w. j a  v  a 2 s .c  om
    }
    if (getSupportActionBar() != null) {
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    }

    fm = getSupportFragmentManager();

    if (savedInstanceState != null) {
        streamerName = savedInstanceState.getString(STREAMER_NAME);
        streamerId = savedInstanceState.getLong(STREAMER_ID, DEFAULT_NON_EXISTING_VALUE);
    } else {
        Intent startIntent = getIntent();
        if (startIntent.hasExtra(STREAMER_ID) && startIntent.hasExtra(STREAMER_NAME)) {
            streamerName = startIntent.getStringExtra(STREAMER_NAME);
            streamerId = startIntent.getLongExtra(STREAMER_ID, DEFAULT_NON_EXISTING_VALUE);
        }
    }

    chatFragment = createChatFragment();

    userStore.userObservable().compose(bindToLifecycle()).observeOn(AndroidSchedulers.mainThread())
            .subscribe(new DisposableSubscriber<CurrentUser>() {
                @Override
                public void onNext(CurrentUser currentUser) {
                    Log.d(TAG, "UserStore->fetchUser->onNext " + currentUser);
                    user = currentUser;
                    invalidateOptionsMenu();
                }

                @Override
                public void onError(Throwable t) {
                    t.printStackTrace();
                }

                @Override
                public void onComplete() {
                    Log.d(TAG, "UserStore->fetchUser->onComplete");
                }
            });
}

From source file:org.thoughtcrime.securesms.notifications.AndroidAutoReplyReceiver.java

@Override
protected void onReceive(final Context context, Intent intent, final @Nullable MasterSecret masterSecret) {
    if (!REPLY_ACTION.equals(intent.getAction()))
        return;// www  . ja v a 2  s  .com

    Bundle remoteInput = RemoteInput.getResultsFromIntent(intent);

    if (remoteInput == null)
        return;

    final long[] recipientIds = intent.getLongArrayExtra(RECIPIENT_IDS_EXTRA);
    final long threadId = intent.getLongExtra(THREAD_ID_EXTRA, -1);
    final CharSequence responseText = getMessageText(intent);
    final Recipients recipients = RecipientFactory.getRecipientsForIds(context, recipientIds, false);

    if (responseText != null) {
        new AsyncTask<Void, Void, Void>() {
            @Override
            protected Void doInBackground(Void... params) {

                long replyThreadId;

                Optional<RecipientsPreferences> preferences = DatabaseFactory
                        .getRecipientPreferenceDatabase(context).getRecipientsPreferences(recipientIds);
                int subscriptionId = preferences.isPresent()
                        ? preferences.get().getDefaultSubscriptionId().or(-1)
                        : -1;
                long expiresIn = preferences.isPresent() ? preferences.get().getExpireMessages() * 1000 : 0;

                if (recipients.isGroupRecipient()) {
                    Log.i("AndroidAutoReplyReceiver", "GroupRecipient, Sending media message");
                    OutgoingMediaMessage reply = new OutgoingMediaMessage(recipients, responseText.toString(),
                            new LinkedList<Attachment>(), System.currentTimeMillis(), subscriptionId, expiresIn,
                            0);
                    replyThreadId = MessageSender.send(context, masterSecret, reply, threadId, false);
                } else {
                    Log.i("AndroidAutoReplyReceiver", "Sending regular message ");
                    OutgoingTextMessage reply = new OutgoingTextMessage(recipients, responseText.toString(),
                            expiresIn, subscriptionId);
                    replyThreadId = MessageSender.send(context, masterSecret, reply, threadId, false);
                }

                List<MarkedMessageInfo> messageIds = DatabaseFactory.getThreadDatabase(context)
                        .setRead(replyThreadId, true);

                MessageNotifier.updateNotification(context, masterSecret);
                MarkReadReceiver.process(context, messageIds);

                return null;
            }
        }.execute();
    }
}

From source file:net.olejon.mdapp.Icd10ChapterActivity.java

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

    // Intent//from  ww  w  .j av a 2s . c  om
    final Intent intent = getIntent();

    mChapterId = intent.getLongExtra("chapter", 0);

    // Input manager
    mInputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);

    // Layout
    setContentView(R.layout.activity_icd10_chapter);

    // Toolbar
    mToolbar = (Toolbar) findViewById(R.id.icd10_chapter_toolbar);
    mToolbar.setTitle("");

    setSupportActionBar(mToolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    mToolbarSearchLayout = (LinearLayout) findViewById(R.id.icd10_chapter_toolbar_search_layout);
    mToolbarSearchEditText = (EditText) findViewById(R.id.icd10_chapter_toolbar_search);

    ImageButton imageButton = (ImageButton) findViewById(R.id.icd10_chapter_toolbar_clear_search);

    imageButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            mToolbarSearchEditText.setText("");
        }
    });

    // Progress bar
    mProgressBar = (ProgressBar) findViewById(R.id.icd10_chapter_toolbar_progressbar);

    mFloatingActionButton = (FloatingActionButton) findViewById(R.id.icd10_chapter_fab);

    mFloatingActionButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            mToolbarSearchLayout.setVisibility(View.VISIBLE);
            mToolbarSearchEditText.requestFocus();

            mInputMethodManager.showSoftInput(mToolbarSearchEditText, 0);
        }
    });

    // List
    mListView = (ListView) findViewById(R.id.icd10_chapter_list);
    mListViewEmpty = findViewById(R.id.icd10_chapter_list_empty);

    // Get data
    GetDataTask getDataTask = new GetDataTask();
    getDataTask.execute();
}

From source file:com.nextgis.woody.activity.EditActivity.java

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

    setContentView(R.layout.activity_edit);
    setToolbar(R.id.main_toolbar);/*from www  .  j a  v a 2  s .c  om*/

    btLeft = (Button) findViewById(R.id.left_button);
    btLeft.setOnClickListener(this);
    btRight = (Button) findViewById(R.id.right_button);
    btRight.setOnClickListener(this);

    values = new ContentValues();

    Intent intent = this.getIntent();
    mFeatureId = intent.getLongExtra(Constants.FEATURE_ID, NOT_FOUND);
    mapCenter = new GeoPoint(intent.getDoubleExtra(SettingsConstants.KEY_PREF_SCROLL_X, 0),
            intent.getDoubleExtra(SettingsConstants.KEY_PREF_SCROLL_Y, 0));

    if (NOT_FOUND != mFeatureId) {
        MapBase mapBase = MapBase.getInstance();
        NGWVectorLayer vectorLayer = (NGWVectorLayer) mapBase.getLayerByName(Constants.KEY_MAIN);
        Feature feature = vectorLayer.getFeature(mFeatureId);
        values = feature.getContentValues(true);
    }
    firstStep();
}