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.example.android.popularmovies.activities.MovieDetailsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_movie_details);
    ButterKnife.bind(this);

    setSupportActionBar(mToolbar);/*from w w  w. j a va 2  s. com*/
    if (getSupportActionBar() != null) {
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setDisplayShowHomeEnabled(true);
    }

    mTabLayout.addTab(mTabLayout.newTab().setText(getString(R.string.details)));
    mTabLayout.addTab(mTabLayout.newTab().setText(getString(R.string.reviews)));
    mTabLayout.addTab(mTabLayout.newTab().setText(getString(R.string.trailers)));
    mTabLayout.setTabGravity(TabLayout.GRAVITY_FILL);

    Intent intentThatStartedThisActivity = getIntent();
    if (intentThatStartedThisActivity.hasExtra(Movie.TAG)) {
        mMovie = intentThatStartedThisActivity.getParcelableExtra(Movie.TAG);
    }
    onRestore(intentThatStartedThisActivity.getExtras());

}

From source file:com.gsma.rcs.ri.messaging.filetransfer.FileTransferIntentService.java

private void handleUndeliveredFileTransfer(Intent intent, String transferId) {
    ContactId contact = intent.getParcelableExtra(FileTransferIntent.EXTRA_CONTACT);
    if (contact == null) {
        if (LogUtils.isActive) {
            Log.e(LOGTAG, "Cannot read contact for ftId=".concat(transferId));
        }//from ww w  .  j  ava  2 s  . c om
        return;
    }
    if (LogUtils.isActive) {
        Log.d(LOGTAG, "Undelivered file transfer ID=" + transferId + " for contact " + contact);
    }
    forwardUndeliveredFileTransferToUi(intent, contact);
}

From source file:com.meetingninja.csse.meetings.ViewMeetingActivity.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == 5) {
        if (resultCode == RESULT_OK) {
            if (data != null) {
                displayedMeeting = data.getParcelableExtra(Keys.Meeting.PARCEL);
                setMeeting();//from w  w  w  .  jav a 2s . co m
                this.resultCode = resultCode;
            }
        } else if (resultCode == RESULT_CANCELED) {
            // do nothing here
        }
    }
}

From source file:com.morlunk.leeroy.LeeroyUpdateService.java

@Override
protected void onHandleIntent(Intent intent) {
    if (intent != null) {
        final String action = intent.getAction();
        final ResultReceiver receiver = intent.getParcelableExtra(EXTRA_RECEIVER);
        if (ACTION_CHECK_UPDATES.equals(action)) {
            final boolean notify = intent.getBooleanExtra(EXTRA_NOTIFY, false);
            handleCheckUpdates(intent, notify, receiver);
        }/*from   www  .  ja va2s.  c  o  m*/
    }
}

From source file:com.bluros.updater.service.DownloadService.java

@Override
protected void onHandleIntent(Intent intent) {
    mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
    mInfo = intent.getParcelableExtra(EXTRA_UPDATE_INFO);

    if (mInfo == null) {
        Log.e(TAG, "Intent UpdateInfo extras were null");
        return;//from  www  .j a  va 2 s  .  c o  m
    }

    try {
        getIncremental();
    } catch (IOException e) {
        downloadFullZip();
    }
}

From source file:com.radiofarda.istgah.ui.PodcastsActivity.java

private void startFullScreenActivityIfNeeded(Intent intent) {
    if (intent != null && intent.getBooleanExtra(EXTRA_START_FULLSCREEN, false)) {
        Parcelable parcelableExtra = intent.getParcelableExtra(EXTRA_CURRENT_MEDIA_DESCRIPTION);
        Intent fullScreenIntent = new Intent(this, FullScreenPlayerActivity.class)
                .setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP)
                .putExtra(EXTRA_CURRENT_MEDIA_DESCRIPTION, parcelableExtra);
        startActivity(fullScreenIntent);
    }/*from   w w  w. j a  va2 s.  c o m*/
}

From source file:com.marpies.ane.facebook.accountkit.functions.LoginFunction.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == AK_APP_REQUEST_CODE) {
        AccountKitLoginResult loginResult = data.getParcelableExtra(AccountKitLoginResult.RESULT_KEY);
        /* Error logging in */
        if (loginResult.getError() != null) {
            AIR.log("AccountKit | login error: " + loginResult.getError().getErrorType().getMessage());
            AIR.dispatchEvent(AccountKitEvent.LOGIN_ERROR, StringUtils.getEventErrorJSON(mCallbackId,
                    loginResult.getError().getErrorType().getMessage()));
        }/*  www. ja v a2s .c  o m*/
        /* Login cancelled */
        else if (loginResult.wasCancelled()) {
            AIR.log("AccountKit | login cancelled");
            AIR.dispatchEvent(AccountKitEvent.LOGIN_CANCEL, String.valueOf(mCallbackId));
        }
        /* Login success */
        else {
            AIR.log("AccountKit | final auth state: " + loginResult.getFinalAuthorizationState());
            JSONObject response = new JSONObject();
            if (loginResult.getAccessToken() != null) {
                addToResponse(response, "accessToken", AKAccessTokenUtils.toJSON(loginResult.getAccessToken()));
                AIR.log("AccountKit | login got access token: " + loginResult.getAccessToken().getAccountId());
                // access token is accessible using AccountKit.getCurrentAccessToken(), no need to store it manually
            } else if (loginResult.getAuthorizationCode() != null) {
                addToResponse(response, "authCode", loginResult.getAuthorizationCode());
                AIR.log("AccountKit | login got auth code: " + loginResult.getAuthorizationCode());
            }

            AIR.log("AccountKit | success logging in");
            /* Dispatch response */
            String authState = (loginResult.getFinalAuthorizationState() == null) ? ""
                    : loginResult.getFinalAuthorizationState();
            addToResponse(response, "authState", authState);
            addToResponse(response, "callbackId", mCallbackId);
            AIR.dispatchEvent(AccountKitEvent.LOGIN_SUCCESS, response.toString());
        }

        AndroidActivityWrapper.GetAndroidActivityWrapper().removeActivityResultListener(this);
    }
}

From source file:com.adkdevelopment.yalantisinternship.DetailFragment.java

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

    View rootView = inflater.inflate(R.layout.detail_fragment_task, container, false);
    ButterKnife.bind(this, rootView);

    Intent intent = getActivity().getIntent();
    RSSNewsItem mNewsItem;/*from w ww  .  j  a v  a  2s  . com*/

    if (intent.hasExtra(RSSNewsItem.TASKITEM)) {
        mNewsItem = intent.getParcelableExtra(RSSNewsItem.TASKITEM);

        // Time parsing and creating a nice textual version (should be changed to Calendar)
        String dateCreated = Utilities.getNiceDate(mNewsItem.getCreated());
        String dateRegistered = Utilities.getNiceDate(mNewsItem.getRegistered());
        String dateAssigned = Utilities.getNiceDate(mNewsItem.getAssigned());

        task_title_text.setText(mNewsItem.getOwner());
        task_status.setText(mNewsItem.getStatus());
        task_created_date.setText(dateCreated);
        task_registered_date.setText(dateRegistered);
        task_assigned_date.setText(dateAssigned);
        task_responsible_name.setText(mNewsItem.getResponsible());
        task_description.setText(Html.fromHtml(mNewsItem.getDescription()));

    } else {
        // If there is no outside intent - fetch example photos
        ArrayList<String> dummyPhotos = new ArrayList<>();
        dummyPhotos.addAll(Arrays.asList(getResources().getStringArray(R.array.task_image_links)));

        mNewsItem = new RSSNewsItem();
        mNewsItem.setPhoto(dummyPhotos);
    }

    // To boost performance as we know that size won't change
    recyclerView.setHasFixedSize(true);

    // Horizontal LayoutManager
    RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getContext(), RecyclerView.HORIZONTAL,
            false);

    recyclerView.setLayoutManager(layoutManager);

    // Adapter with data about different activities
    PhotoAdapter photoAdapter = new PhotoAdapter(mNewsItem.getPhoto(), getContext());
    recyclerView.setAdapter(photoAdapter);

    return rootView;
}

From source file:com.polyvi.xface.extension.XNetworkConnectionExt.java

/**
 * ? plugin  NetworkConnection .//w w  w  . ja  va 2 s  .co  m
 *  Android ??BroadcastReceiver Android  broadcast
 *
 */
public void initConnectionContext() {
    Context context = getContext();
    this.mSockMan = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);

    // ????connection
    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
    if (this.mReceiver == null) {
        this.mReceiver = new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                updateConnectionInfo(
                        (NetworkInfo) intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO));
            }
        };
        context.registerReceiver(this.mReceiver, intentFilter);
    }
}

From source file:es.udc.fic.android.robot_control.robot.ConectorPlaca.java

public void conectar(Context ctx, Intent intent) throws TransmisionErrorException {

    Log.i(C.ROBOT_TAG, "Conectando a [ " + intent.getAction() + " ]. modo - Host");
    device = intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);
    Log.i(C.ROBOT_TAG, "Conectando a [ " + device.getDeviceName() + " ]. modo - Host");
    /* Get the USB manager from the requesting context */
    this.manager = (UsbManager) ctx.getSystemService(Context.USB_SERVICE);
    conectar();/*from   w  ww  .  ja  v a2 s  .  c o m*/
}