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:website.openeng.anki.Reviewer.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == REQUEST_STATISTICS || requestCode == REQUEST_BROWSE_CARDS) {
        // select original deck if the statistics or card browser were opened,
        // which can change the selected deck
        if (data.hasExtra("originalDeck")) {
            getCol().getDecks().select(data.getLongExtra("originalDeck", 0L));
        }//  w w w . j av  a 2s.  co m
    } else {
        super.onActivityResult(requestCode, resultCode, data);
    }
}

From source file:com.eusecom.attendance.StorageActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_storage);

    // Initialize Firebase Auth
    mAuth = FirebaseAuth.getInstance();//from w w  w. ja  v a  2s  .  co m

    // Initialize Firebase Storage Ref
    // [START get_storage_ref]
    mStorageRef = FirebaseStorage.getInstance().getReference();
    // [END get_storage_ref]

    // Click listeners
    findViewById(R.id.button_camera).setOnClickListener(this);
    findViewById(R.id.button_sign_in).setOnClickListener(this);
    findViewById(R.id.button_download).setOnClickListener(this);

    // Restore instance state
    if (savedInstanceState != null) {
        mFileUri = savedInstanceState.getParcelable(KEY_FILE_URI);
        mDownloadUrl = savedInstanceState.getParcelable(KEY_DOWNLOAD_URL);
    }

    // Download receiver
    mDownloadReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            Log.d(TAG, "downloadReceiver:onReceive:" + intent);
            hideProgressDialog();

            if (com.eusecom.attendance.MyDownloadService.ACTION_COMPLETED.equals(intent.getAction())) {
                String path = intent
                        .getStringExtra(com.eusecom.attendance.MyDownloadService.EXTRA_DOWNLOAD_PATH);
                long numBytes = intent
                        .getLongExtra(com.eusecom.attendance.MyDownloadService.EXTRA_BYTES_DOWNLOADED, 0);

                // Alert success
                showMessageDialog("Success",
                        String.format(Locale.getDefault(), "%d bytes downloaded from %s", numBytes, path));
            }

            if (com.eusecom.attendance.MyDownloadService.ACTION_ERROR.equals(intent.getAction())) {
                String path = intent
                        .getStringExtra(com.eusecom.attendance.MyDownloadService.EXTRA_DOWNLOAD_PATH);

                // Alert failure
                showMessageDialog("Error",
                        String.format(Locale.getDefault(), "Failed to download from %s", path));
            }
        }
    };
}

From source file:org.getlantern.firetweet.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);
        }/*from w ww  .j  av  a2  s .  c o  m*/
    }
    mMainContent.setOnFitSystemWindowsListener(this);
    mUsersSearchAdapter = new SuggestionsAdapter(this);
    mSuggestionsList.setAdapter(mUsersSearchAdapter);
    mSuggestionsList.setOnItemClickListener(this);
    final SwipeDismissListViewTouchListener listener = new SwipeDismissListViewTouchListener(mSuggestionsList,
            this);
    mSuggestionsList.setOnTouchListener(listener);
    mSuggestionsList.setOnScrollListener(listener.makeScrollListener());
    mSearchSubmit.setOnClickListener(this);
    mSearchQuery.setOnEditorActionListener(this);
    mSearchQuery.addTextChangedListener(this);

    getSupportLoaderManager().initLoader(0, null, this);
}

From source file:com.app.encontreibvrr.uploadImagem.MainActivityStorage.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main_upload);

    // Initialize Firebase Auth
    mAuth = FirebaseAuth.getInstance();/*www.j  a  va 2 s.  co m*/

    // Initialize Firebase Storage Ref
    // [START get_storage_ref]
    mStorageRef = FirebaseStorage.getInstance().getReference();
    // [END get_storage_ref]

    // Click listeners
    findViewById(R.id.button_camera).setOnClickListener(this);
    findViewById(R.id.button_sign_in).setOnClickListener(this);
    findViewById(R.id.button_download).setOnClickListener(this);

    // Restore instance state
    if (savedInstanceState != null) {
        mFileUri = savedInstanceState.getParcelable(KEY_FILE_URI);
        mDownloadUrl = savedInstanceState.getParcelable(KEY_DOWNLOAD_URL);
    }
    // Restore instance state
    if (savedInstanceState != null) {
        mFileUri = savedInstanceState.getParcelable(KEY_FILE_URI);
        mDownloadUrl = savedInstanceState.getParcelable(KEY_DOWNLOAD_URL);
    }

    // Download receiver
    mDownloadReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            Log.d(TAG, "downloadReceiver:onReceive:" + intent);
            hideProgressDialog();

            if (MyDownloadService.ACTION_COMPLETED.equals(intent.getAction())) {
                String path = intent.getStringExtra(MyDownloadService.EXTRA_DOWNLOAD_PATH);
                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, path));
            }

            if (MyDownloadService.ACTION_ERROR.equals(intent.getAction())) {
                String path = intent.getStringExtra(MyDownloadService.EXTRA_DOWNLOAD_PATH);

                // Alert failure
                showMessageDialog("Error",
                        String.format(Locale.getDefault(), "Failed to download from %s", path));
            }
        }
    };
}

From source file:com.android.contacts.activities.ContactSelectionActivity.java

private long getTargetContactId() {
    Intent intent = getIntent();
    final long targetContactId = intent.getLongExtra(UiIntentActions.TARGET_CONTACT_ID_EXTRA_KEY, -1);
    if (targetContactId == -1) {
        Log.e(TAG, "Intent " + intent.getAction() + " is missing required extra: "
                + UiIntentActions.TARGET_CONTACT_ID_EXTRA_KEY);
        setResult(RESULT_CANCELED);/*from   ww w  .j a  va2  s.c  o  m*/
        finish();
        return -1;
    }
    return targetContactId;
}

From source file:com.swetha.easypark.GetIndividualParkingSpotDetails.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.i("GetIndividualParkingSpotDetails", "Before Set ContentView");
    mContext = this.getApplicationContext();
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);

    setContentView(R.layout.listvacantparkingspots);
    Log.i("GetIndividualParkingSpotDetails", "After Set ContentView");

    Intent thisIntent = getIntent();
    parkingLotId = thisIntent.getStringExtra("individualParkingLotId");
    fromTime = thisIntent.getLongExtra(GetParkingLots.FROMTIME, 0);
    toTime = thisIntent.getLongExtra(GetParkingLots.TOTIME, 0);

    Log.i("GetIndividualParkingSpotDetails", "After getting from intent" + fromTime + toTime + parkingLotId);

    /*   Test Data/*from w ww .  j a  va2s  .com*/
     * parkingSpotMapList = new ArrayList<LinkedHashMap<String, String>>();
       LinkedHashMap<String, String> parkingSpotMap = new LinkedHashMap<String, String>();
               
       parkingSpotMap.put("parkingspotid", parkingLotId);
       Log.i("GetIndividualParkingSpotDetails", "PArking lot id" +parkingLotId);
       parkingSpotMap.put("vacantspotdisplay", "A5");
       LinkedHashMap<String, String> parkingSpotMap2 = new LinkedHashMap<String, String>();
               
       parkingSpotMap2.put("parkingspotid", "2");
       parkingSpotMap2.put("vacantspotdisplay", "A6");
               
       parkingSpotMapList.add(parkingSpotMap);
       parkingSpotMapList.add(parkingSpotMap2);*/

    new GetParkingSpotsFromWebService(this, fromTime, toTime).execute();
    Log.i("GetIndividualParkingSpotDetails", "After adding to hashmap list");

    btn_next = (Button) findViewById(R.id.single_selection_btn_first);
    btn_next.setClickable(true);
    btn_next.setFocusable(true);
    Log.i("GetIndividualParkingSpotDetails", "After firstbutton focussable");
    btn_next.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {

            //ListView l = getListView();
            //TextSelectedView l_v = (TextSelectedView)v;

            HashMap<String, String> hmap = parkingSpotMapList.get(mSelectedItem);
            Log.i("GetIndividualParkingSpotDetails", "The value of mSelectedItem:" + mSelectedItem);
            theParkingSpotName = hmap.get("vacantspotdisplay");
            theParkingSpotId = hmap.get("parkingspotid");

            Log.i("GetIndividualParkingSpotDetails", "The selected parking spot  is " + theParkingSpotName);
            Log.i("GetIndividualParkingSpotDetails", "The selected parking spotid  is " + theParkingSpotId);

            chk_default = (CheckBox) findViewById(R.id.single_selection_chkbox_default);
            new UpdateParkingSpotThroughWebService(GetIndividualParkingSpotDetails.this, theParkingSpotId,
                    fromTime, toTime).execute();

        }
    });
    Log.i("GetIndividualParkingSpotDetails", "After settOnClickListener first button");
    btn_back = (Button) findViewById(R.id.single_selection_btn_second);
    btn_back.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            //close the activity
            finish();
        }
    });
    Log.i("GetIndividualParkingSpotDetails", "After settOnClickListener second button");

    chk_default = (CheckBox) findViewById(R.id.single_selection_chkbox_default);
    chk_default.setChecked(false);
    Log.i("GetIndividualParkingSpotDetails", "After checkbox");

    //tv_ins = (TextView) this.findViewById(R.id.single_selection_chkbox_default_text);
    //tv_ins.setText("Test");
    Log.i("GetIndividualParkingSpotDetails", "After textView end of oncreate");
}

From source file:me.jreilly.JamesTweet.TweetView.TweetFragment.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Intent intent = getActivity().getIntent();
    if (intent != null && intent.hasExtra(TweetActivity.TWEET_KEY)) {
        //Get the ID of the tweet to be displayed
        mTweetId = intent.getLongExtra(TweetActivity.TWEET_KEY, 0);

        //Get the database in which this tweet is stored
        mRealmLoc = intent.getStringExtra(TweetActivity.REALM_KEY);
        Log.v(LOG_TAG, "Got Tweet id: " + mTweetId);

    }/*from  w  w w . j  av  a 2 s .  c o  m*/

}

From source file:com.rerum.beans.StorageActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_storage);

    // Initialize Firebase Auth
    mAuth = FirebaseAuth.getInstance();/*  ww  w  . ja va  2s  . c  o m*/

    // Initialize Firebase Storage Ref
    // [START get_storage_ref]
    mStorageRef = FirebaseStorage.getInstance().getReference();
    // [END get_storage_ref]

    // Click listeners
    findViewById(R.id.button_camera).setOnClickListener(this);
    findViewById(R.id.button_sign_in).setOnClickListener(this);
    findViewById(R.id.button_download).setOnClickListener(this);

    // Restore instance state
    if (savedInstanceState != null) {
        mFileUri = savedInstanceState.getParcelable(KEY_FILE_URI);
        mDownloadUrl = savedInstanceState.getParcelable(KEY_DOWNLOAD_URL);
    }

    // Download receiver
    mDownloadReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            Log.d(TAG, "downloadReceiver:onReceive:" + intent);
            hideProgressDialog();

            if (MyDownloadService.ACTION_COMPLETED.equals(intent.getAction())) {
                String path = intent.getStringExtra(MyDownloadService.EXTRA_DOWNLOAD_PATH);
                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, path));
            }

            if (MyDownloadService.ACTION_ERROR.equals(intent.getAction())) {
                String path = intent.getStringExtra(MyDownloadService.EXTRA_DOWNLOAD_PATH);

                // Alert failure
                showMessageDialog("Error",
                        String.format(Locale.getDefault(), "Failed to download from %s", path));
            }
        }
    };
}

From source file:org.y20k.transistor.helpers.SleepTimerService.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {

    // checking for empty intent
    if (intent == null) {
        LogHelper.v(LOG_TAG, "Null-Intent received. Stopping self.");
        stopSelf();/*from w  w  w. j  a v  a  2 s .c om*/
    }

    // ACTION TIMER START
    else if (intent.getAction().equals(TransistorKeys.ACTION_TIMER_START)) {
        LogHelper.v(LOG_TAG, "Service received command: START");

        if (intent.hasExtra(TransistorKeys.EXTRA_TIMER_DURATION)) {
            // get duration from intent
            long duration = intent.getLongExtra(TransistorKeys.EXTRA_TIMER_DURATION, 0);

            // set remaining time
            if (mTimerRemaining > 0) {
                mTimerRemaining = mTimerRemaining + duration;
            } else {
                mTimerRemaining = duration;
            }

            // set sleep timer
            setSleepTimer(mTimerRemaining);

            // start countdown
            mSleepTimer.start();

            // save timer state to preferences
            saveTimerState(true);
        }

    }

    // ACTION TIMER STOP
    else if (intent.getAction().equals(TransistorKeys.ACTION_TIMER_STOP)) {
        LogHelper.v(LOG_TAG, "Service received command: STOP");

        // set remaining time
        mTimerRemaining = 0;

        // cancel timer
        if (mSleepTimer != null) {
            mSleepTimer.cancel();
        }

        // save timer state to preferences
        saveTimerState(false);

    }

    // START_STICKY is used for services that are explicitly started and stopped as needed
    return START_STICKY;

}

From source file:com.nbplus.vbroadlauncher.service.BroadcastChatHeadService.java

private void createBroadcastChatHead(Intent intent) {
    if (intent == null) {
        return;//w  w w.j av a 2  s. c o m
    }

    mBroadcastData = intent.getParcelableExtra(Constants.EXTRA_BROADCAST_PAYLOAD_DATA);
    if (mBroadcastData == null) {
        Log.d(TAG, "Broadcast data is not found!!!");
        return;
    }
    long mBroadcastIndex = intent.getLongExtra(Constants.EXTRA_BROADCAST_PAYLOAD_INDEX, -1);
    String pushType = mBroadcastData.getServiceType();
    if (!Constants.PUSH_PAYLOAD_TYPE_NORMAL_BROADCAST.equals(pushType)
            && !Constants.PUSH_PAYLOAD_TYPE_REALTIME_BROADCAST.equals(pushType)
            && !Constants.PUSH_PAYLOAD_TYPE_TEXT_BROADCAST.equals(pushType)) {
        Log.d(TAG, "This is not broadcast push type !!!");
        return;
    }
    if (mIsPlaying && mChatHead != null) {
        removeChatHead(true);
    }

    mIsPlaying = true;

    int layout = -1;
    if (Constants.PUSH_PAYLOAD_TYPE_TEXT_BROADCAST.equals(pushType)) {
        layout = R.layout.fragment_text_broadcast;
    } else {
        layout = R.layout.fragment_audio_broadcast;
    }
    mChatHead = inflater.inflate(layout, null);

    if (Constants.PUSH_PAYLOAD_TYPE_TEXT_BROADCAST.equals(mBroadcastData.getServiceType())) {
        // ?
        mTextView = (TextView) mChatHead.findViewById(R.id.broadcast_text);
        mTextView.setText(mBroadcastData.getMessage());
        mTextView.setVerticalScrollBarEnabled(true);
        mTextView.setHorizontalScrollBarEnabled(false);
        mTextView.setMovementMethod(new ScrollingMovementMethod());

        mText2SpeechHandler = new TextToSpeechHandler(this, this);
        mText2Speech = new TextToSpeech(this, this);
    } else {
        // , ??
        mWebView = (WebView) mChatHead.findViewById(R.id.webview);
        mWebViewClient = new RealtimeBroadcastWebViewClient(this, mWebView, this);
        mWebViewClient.setBackgroundTransparent();

        String url = mBroadcastData.getMessage();
        if (url.indexOf("?") > 0) {
            if (!url.contains("UUID=")) {
                url += ("&UUID=" + LauncherSettings.getInstance(this).getDeviceID());
            }
            if (!url.contains("APPID=")) {
                url += ("&APPID=" + getApplicationContext().getPackageName());
            }
        } else {
            if (!url.contains("UUID=")) {
                url += ("?UUID=" + LauncherSettings.getInstance(this).getDeviceID());
            }
            if (!url.contains("APPID=")) {
                if (!url.contains("UUID=")) {
                    url += ("?APPID=" + getApplicationContext().getPackageName());
                } else {
                    url += ("&APPID=" + getApplicationContext().getPackageName());
                }
            }
        }
        mWebViewClient.loadUrl(url);
    }
    mChatHead.setTag(mBroadcastIndex);

    //        mChatHead.findViewById(R.id.btn_dismiss).setOnClickListener(new View.OnClickListener() {
    //            @Override
    //            public void onClick(View v) {
    //                removeChatHead();
    //            }
    //        });

    /**
     * To create an overlay view, when setting up the LayoutParams DON'T set the type to TYPE_SYSTEM_OVERLAY.
            
     Instead set it to TYPE_PHONE.
            
     Use the following flags:
     FLAG_NOT_TOUCH_MODAL
     FLAG_WATCH_OUTSIDE_TOUCH
     FLAG_NOT_TOUCH_MODAL << I found this one to be quite important. Without it,
     focus is given to the overlay and soft-key (home, menu, etc.) presses are not passed to the activity below.
     */
    int flag = WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY;

    final WindowManager.LayoutParams params = new WindowManager.LayoutParams(
            WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT, flag, 0,
            PixelFormat.TRANSLUCENT);

    params.gravity = Gravity.CENTER;

    /**
     * do not use...
    mChatHead.findViewById(R.id.txt_title).setOnTouchListener(new View.OnTouchListener() {
    private int initialX;
    private int initialY;
    private float initialTouchX;
    private float initialTouchY;
            
    @Override
    public boolean onTouch(View v, MotionEvent event) {
        switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
                initialX = params.x;
                initialY = params.y;
                initialTouchX = event.getRawX();
                initialTouchY = event.getRawY();
                return true;
            case MotionEvent.ACTION_UP:
                return true;
            case MotionEvent.ACTION_MOVE:
                params.x = initialX + (int) (event.getRawX() - initialTouchX);
                params.y = initialY + (int) (event.getRawY() - initialTouchY);
                windowManager.updateViewLayout(mChatHead, params);
                return true;
        }
        return false;
    }
    });
    */
    addChatHead(mChatHead, params);
}