Example usage for android.content Intent getParcelableExtra

List of usage examples for android.content Intent getParcelableExtra

Introduction

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

Prototype

public <T extends Parcelable> T getParcelableExtra(String name) 

Source Link

Document

Retrieve extended data from the intent.

Usage

From source file:com.google.samples.apps.iosched.ui.NfcBadgeActivity.java

@Override
public void onStart() {
    super.onStart();
    AnalyticsManager.initializeAnalyticsTracker(getApplicationContext());
    // Check for NFC data
    Intent i = getIntent();
    if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(i.getAction())) {
        LOGI(TAG, "Badge detected");
        /* [ANALYTICS:EVENT]
         * TRIGGER:   Scan another attendee's badge.
         * CATEGORY:  'NFC'/*  ww w  .  jav a  2 s.  c  om*/
         * ACTION:    'Read'
         * LABEL:     'Badge'. Badge info IS NOT collected.
         * [/ANALYTICS]
         */
        AnalyticsManager.sendEvent("NFC", "Read", "Badge");
        readTag((Tag) i.getParcelableExtra(NfcAdapter.EXTRA_TAG));
    } else if (ACTION_SIMULATE.equals(i.getAction()) && Config.IS_DOGFOOD_BUILD) {
        String simulatedUrl = i.getDataString();
        LOGD(TAG, "Simulating badge scanning with URL " + simulatedUrl);
        // replace https by Unicode character 4, as per normal badge encoding rules
        recordBadge(simulatedUrl.replace("https://", "\u0004"));
    } else {
        LOGW(TAG, "Invalid action in Intent to NfcBadgeActivity: " + i.getAction());
    }
    finish();
}

From source file:com.google.android.apps.iosched.ui.AccountActivity.java

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

    setContentView(R.layout.activity_letterboxed_when_large);

    final Intent intent = getIntent();
    if (intent.hasExtra(EXTRA_FINISH_INTENT)) {
        mFinishIntent = intent.getParcelableExtra(EXTRA_FINISH_INTENT);
    }//w w w .j av a2 s  .  co m

    if (savedInstanceState == null) {
        if (!AccountUtils.isAuthenticated(this)) {
            getSupportFragmentManager().beginTransaction()
                    .add(R.id.root_container, new SignInMainFragment(), "signin_main").commit();
        } else {
            mChosenAccount = new Account(AccountUtils.getChosenAccountName(this), "com.google");
            getSupportFragmentManager().beginTransaction().add(R.id.root_container,
                    SignInSetupFragment.makeFragment(SETUP_ATTENDEE), "setup_attendee").commit();
        }
    } else {
        String accountName = savedInstanceState.getString(KEY_CHOSEN_ACCOUNT);
        if (accountName != null) {
            mChosenAccount = new Account(accountName, "com.google");
            mPlusClient = (new PlusClient.Builder(this, this, this)).setAccountName(accountName)
                    .setScopes(AccountUtils.AUTH_SCOPES).build();
        }
    }
}

From source file:com.putlocker.upload.DownloadService.java

private void handleDownloadIntent(Intent intent) {
    baseFile = new File("/mnt/sdcard/", "putlocker");
    final PutlockerDownloadJob job = intent.getParcelableExtra(JOB_EXTRA_DOWNLOAD);
    if (cancelledJobs.get(job.getGlobalId()) != null) {
        cancelledJobs.remove(job.getGlobalId());
    } else {//ww w . j a  v a  2  s.c  om
        _download.put((long) job.getGlobalId(), job);
        if (!baseFile.exists()) {
            if (!baseFile.mkdir()) {
                Toast.makeText(getApplicationContext(), "Could not download, must have an SDCard",
                        Toast.LENGTH_LONG);
                setPutlockerJobStatus(job, DownloadStatus.JobError);
                return;
            }
        }
        /*
         * Update our current file location
         */
        File newFile = new File(baseFile, String.valueOf(job._fileName));

        job.setFileLocation(newFile.getAbsolutePath());

        getPutlockerApplication().getStorage().UpdateTyped(job);
        Log.e("Julian", "Job id " + String.valueOf(job.getId()));
        RequestCallback callback = new RequestCallback() {
            @Override
            public void requestSuccess(HttpFetch fetch) {
                job.setStatus(DownloadStatus.JobSucess);
                setPutlockerJobStatus(job, DownloadStatus.JobSucess);
                _download.remove(job.getGlobalId());
            }

            @Override
            public void requestRetry(HttpFetch fetch) {
            }

            @Override
            public void requestFailure(HttpFetch fetch) {
                job.setStatus(DownloadStatus.JobError);
                _download.remove(job.getGlobalId());
                setPutlockerJobStatus(job, DownloadStatus.JobError);
                _mainThread.post(new Runnable() {

                    @Override
                    public void run() {

                        Toast.makeText(getApplicationContext(), R.string.download_failed, Toast.LENGTH_LONG);
                    }
                });

            }
        };
        PutlockerFileDownload download = new PutlockerFileDownload(job, this, callback, newFile);
        runningJobs.append(job.getGlobalId(), download);
        download.run();

        runningJobs.remove(job.getGlobalId());
        if (download.getStatus().equals(RequestStatus.RequestStatusCanceled)) {
            job.setStatus(DownloadStatus.JobError);
            setPutlockerJobStatus(job, DownloadStatus.JobError);
        }
    }
    downloadJobs.remove(job.getGlobalId());
    mNM.cancel(job.getGlobalId());
    // At the end we are going to update the status of the job
    getPutlockerApplication().getStorage().UpdateTyped(job);
    // We are going to stop the foreground services

    if (downloadJobs.size() == 0) {
        stopForeground(true);
    }
    doCompleteNotification(job, job.getStatus());
}

From source file:com.gdgdevfest.android.apps.devfestbcn.ui.AccountActivity.java

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

    setContentView(R.layout.activity_letterboxed_when_large);

    final Intent intent = getIntent();
    if (intent.hasExtra(EXTRA_FINISH_INTENT)) {
        mFinishIntent = intent.getParcelableExtra(EXTRA_FINISH_INTENT);
    }/* w w w .j  av a 2s  .  c o  m*/

    if (savedInstanceState == null) {
        if (!AccountUtils.isAuthenticated(this)) {
            getSupportFragmentManager().beginTransaction()
                    .add(R.id.root_container, new SignInMainFragment(), "signin_main").commit();
        } else {
            mChosenAccount = new Account(AccountUtils.getChosenAccountName(this), "com.google");
            getSupportFragmentManager().beginTransaction().add(R.id.root_container,
                    SignInSetupFragment.makeFragment(SETUP_ATTENDEE), "setup_attendee").commit();
        }
    } else {
        String accountName = savedInstanceState.getString(KEY_CHOSEN_ACCOUNT);
        if (accountName != null) {
            mChosenAccount = new Account(accountName, "com.google");
            //     mPlusClient = (new PlusClient.Builder(this, this, this))
            //             .setAccountName(accountName)
            //             .setScopes(AccountUtils.AUTH_SCOPES)
            //            .build();
        }
    }
}

From source file:com.javadog.cgeowear.cgeoWear.java

/**
 * Initializes the screen, whether the Activity was freshly-launched or onNewIntent was run.
 *
 * @param i The launch intent./*from w ww  .j  a  v a 2  s.c  om*/
 */
private void initScreen(Intent i) {
    String cacheName = i.getStringExtra(MessageDataSet.KEY_CACHE_NAME);
    String geocode = i.getStringExtra(MessageDataSet.KEY_GEOCODE);
    distance = i.getFloatExtra(MessageDataSet.KEY_DISTANCE, 0f);
    direction = i.getFloatExtra(MessageDataSet.KEY_DIRECTION, 0f);
    geocacheLocation = i.getParcelableExtra(MessageDataSet.KEY_CACHE_LOCATION);

    //Start listening for compass updates, if the user wants
    useWatchCompass = i.getBooleanExtra(MessageDataSet.KEY_WATCH_COMPASS, false);
    if (accelerometer != null && magnetometer != null) {
        sensorManager.unregisterListener(this, accelerometer);
        sensorManager.unregisterListener(this, magnetometer);
    }
    Log.d(DEBUG_TAG, useWatchCompass ? "Using watch compass." : "Using phone compass.");
    if (useWatchCompass) {
        sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
        accelerometer = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
        magnetometer = sensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD);
        sensorManager.registerListener(this, accelerometer, SensorManager.SENSOR_DELAY_NORMAL);
        sensorManager.registerListener(this, magnetometer, SensorManager.SENSOR_DELAY_NORMAL);
    }

    tv_cacheName.setText(cacheName);
    tv_geocode.setText(geocode);
    setDistanceFormatted(distance);
    rotateCompass(direction);
}

From source file:com.linroid.pushapp.service.DownloadService.java

@DebugLog
@Override/*ww  w  .j  av  a2s.co  m*/
public int onStartCommand(Intent intent, int flags, int startId) {
    if (intent == null || !intent.hasExtra(EXTRA_PACKAGE)) {
        //            throw new IllegalArgumentException("require push info extra");
        Timber.e("require package info extra");
        return super.onStartCommand(intent, flags, startId);
    }
    Timber.d("Bundle: %s", AndroidUtil.sprintBundle(intent.getExtras()));
    Pack pack = intent.getParcelableExtra(EXTRA_PACKAGE);
    newDownloadTask(pack);
    return super.onStartCommand(intent, flags, startId);
}

From source file:com.ctg.ctvideo.activities.VideoActivity.java

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

    mSettings = new Settings(this);

    // handle arguments
    mVideoPath = getIntent().getStringExtra("videoUrl");

    Intent intent = getIntent();
    String intentAction = intent.getAction();
    if (!TextUtils.isEmpty(intentAction)) {
        if (intentAction.equals(Intent.ACTION_VIEW)) {
            mVideoPath = intent.getDataString();
        } else if (intentAction.equals(Intent.ACTION_SEND)) {
            mVideoUri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                String scheme = mVideoUri.getScheme();
                if (TextUtils.isEmpty(scheme)) {
                    Log.e(TAG, "Null unknown ccheme\n");
                    finish();//  ww w  . j a v a2 s  . com
                    return;
                }
                if (scheme.equals(ContentResolver.SCHEME_ANDROID_RESOURCE)) {
                    mVideoPath = mVideoUri.getPath();
                } else if (scheme.equals(ContentResolver.SCHEME_CONTENT)) {
                    Log.e(TAG, "Can not resolve content below Android-ICS\n");
                    finish();
                    return;
                } else {
                    Log.e(TAG, "Unknown scheme " + scheme + "\n");
                    finish();
                    return;
                }
            }
        }
    }

    if (!TextUtils.isEmpty(mVideoPath)) {
        new RecentMediaStorage(this).saveUrlAsync(mVideoPath);
    }

    // init UI
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    ActionBar actionBar = getSupportActionBar();
    mMediaController = new AndroidMediaController(this, false);
    mMediaController.setSupportActionBar(actionBar);

    mToastTextView = (TextView) findViewById(R.id.toast_text_view);
    mHudView = (TableLayout) findViewById(R.id.hud_view);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mRightDrawer = (ViewGroup) findViewById(R.id.right_drawer);

    mDrawerLayout.setScrimColor(Color.TRANSPARENT);

    // init player
    IjkMediaPlayer.loadLibrariesOnce(null);
    IjkMediaPlayer.native_profileBegin("libijkplayer.so");

    mVideoView = (IjkVideoView) findViewById(R.id.video_view);
    mVideoView.setMediaController(mMediaController);
    mVideoView.setHudView(mHudView);

    // 
    mVideoAd = (FrameLayout) findViewById(R.id.video_ad);
    mVideoView.setVideoAd(mVideoAd);
    mVideoView.addVideoAdTask(0, "http://www.pp3.cn/uploads/allimg/111110/15563RI9-7.jpg");
    mVideoView.addVideoAdTask(10000, intent.getStringExtra("videoImg"));
    mVideoView.addVideoAdTask(20000,
            "http://photo.enterdesk.com/2011-2-16/enterdesk.com-1AA0C93EFFA51E6D7EFE1AE7B671951F.jpg");
    mVideoView.addVideoAdTask(15000,
            "https://ss0.bdstatic.com/5aV1bjqh_Q23odCf/static/superman/img/logo/bd_logo1_31bdc765.png");

    // prefer mVideoPath
    if (mVideoPath != null)
        mVideoView.setVideoPath(mVideoPath);
    else if (mVideoUri != null)
        mVideoView.setVideoURI(mVideoUri);
    else {
        Log.e(TAG, "Null Data Source\n");
        finish();
        return;
    }
    mVideoView.start();
}

From source file:com.adkdevelopment.earthquakesurvival.ui.DetailFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.detailed_fragment, container, false);
    setHasOptionsMenu(true);/*  w  ww  .  java  2  s .c  o  m*/

    mUnbinder = ButterKnife.bind(this, rootView);

    if (getActivity().getIntent().hasExtra(Feature.GEOFENCE)) {

        ArrayList<String> place = getActivity().getIntent().getStringArrayListExtra(Feature.GEOFENCE);

        Cursor cursor = null;
        if (place != null && place.size() > 1) {
            cursor = getActivity().getContentResolver().query(EarthquakeColumns.CONTENT_URI, null,
                    EarthquakeColumns.URL + "= ?", new String[] { place.get(1) }, null);
        }

        if (cursor != null && cursor.getCount() > 0) {
            cursor.moveToFirst();

            long dateMillis = cursor.getLong(cursor.getColumnIndex(EarthquakeColumns.TIME));
            double latitude = cursor.getDouble(cursor.getColumnIndex(EarthquakeColumns.LATITUDE));
            double longitude = cursor.getDouble(cursor.getColumnIndex(EarthquakeColumns.LONGITUDE));

            LatLng latLng = new LatLng(latitude, longitude);

            mCameraPosition = CameraPosition.builder().target(latLng).zoom(LocationUtils.CAMERA_DEFAULT_ZOOM)
                    .build();

            mDistance = getString(R.string.earthquake_distance,
                    LocationUtils.getDistance(latLng, LocationUtils.getLocation(getContext())));
            mDate = Utilities.getRelativeDate(dateMillis);
            mDescription = Utilities
                    .formatEarthquakePlace(cursor.getString(cursor.getColumnIndex(EarthquakeColumns.PLACE)));
            mLink = cursor.getString(cursor.getColumnIndex(EarthquakeColumns.URL));
            mMagnitude = cursor.getDouble(cursor.getColumnIndex(EarthquakeColumns.MAG));
            mDepth = cursor.getDouble(cursor.getColumnIndex(EarthquakeColumns.DEPTH)) / 1.6;
            cursor.close();

            setDataToViews();
        }

    } else if (getActivity().getIntent() != null) {
        Intent input = getActivity().getIntent();
        mDate = input.getStringExtra(Feature.DATE);
        mDescription = input.getStringExtra(Feature.PLACE);
        mLink = input.getStringExtra(Feature.LINK);
        mMagnitude = input.getDoubleExtra(Feature.MAGNITUDE, 0.0);
        mPosition = input.getParcelableExtra(Feature.LATLNG);
        mDistance = input.getStringExtra(Feature.DISTANCE);
        mDepth = input.getDoubleExtra(Feature.DEPTH, 0.0);

        setDataToViews();
    }

    if (mPosition == null) {
        mPosition = LocationUtils.getLocation(getContext());
    }

    final Bundle mapViewSavedInstanceState = savedInstanceState != null
            ? savedInstanceState.getBundle(MAP_STATE)
            : null;

    if (Utilities.checkPlayServices(getActivity())) {
        mMapView.onCreate(mapViewSavedInstanceState);
        mMapView.getMapAsync(this);
    }

    if (savedInstanceState != null) {
        mCameraPosition = savedInstanceState.getParcelable(CAMERA_POSITION);
    } else {
        mCameraPosition = CameraPosition.builder().target(mPosition).zoom(LocationUtils.CAMERA_DEFAULT_ZOOM)
                .build();
    }

    return rootView;
}

From source file:com.saarang.samples.apps.iosched.ui.NfcBadgeActivity.java

@Override
public void onStart() {
    super.onStart();
    AnalyticsManager.initializeAnalyticsTracker(getApplicationContext());
    // Check for NFC data
    Intent i = getIntent();
    if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(i.getAction())) {
        LogUtils.LOGI(TAG, "Badge detected");
        /* [ANALYTICS:EVENT]
         * TRIGGER:   Scan another attendee's badge.
         * CATEGORY:  'NFC'// ww w  .  j  a v  a2  s .  co m
         * ACTION:    'Read'
         * LABEL:     'Badge'. Badge info IS NOT collected.
         * [/ANALYTICS]
         */
        AnalyticsManager.sendEvent("NFC", "Read", "Badge");
        readTag((Tag) i.getParcelableExtra(NfcAdapter.EXTRA_TAG));
    } else if (ACTION_SIMULATE.equals(i.getAction()) && Config.IS_DOGFOOD_BUILD) {
        String simulatedUrl = i.getDataString();
        LogUtils.LOGD(TAG, "Simulating badge scanning with URL " + simulatedUrl);
        // replace https by Unicode character 4, as per normal badge encoding rules
        recordBadge(simulatedUrl.replace("https://", "\u0004"));
    } else {
        LogUtils.LOGW(TAG, "Invalid action in Intent to NfcBadgeActivity: " + i.getAction());
    }
    finish();
}

From source file:com.android.mail.photo.MailPhotoViewController.java

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

    mActionHandler = new AttachmentActionHandler(mMailActivity.getContext(), null);
    mActionHandler.initialize(mMailActivity.getFragmentManager());

    final Intent intent = mMailActivity.getIntent();
    mAccountType = intent.getStringExtra(MailPhotoViewActivity.EXTRA_ACCOUNT_TYPE);
    final String account = intent.getStringExtra(MailPhotoViewActivity.EXTRA_ACCOUNT);
    final Message msg = intent.getParcelableExtra(MailPhotoViewActivity.EXTRA_MESSAGE);
    mHideExtraOptionOne = intent.getBooleanExtra(MailPhotoViewActivity.EXTRA_HIDE_EXTRA_OPTION_ONE, false);
    mActionHandler.setAccount(account);//from   w  w  w  . ja  va2  s .  co  m
    mActionHandler.setMessage(msg);
}