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.facebook.notifications.NotificationsManager.java

/**
 * Handle the result of an activity started using
 * {@code prepare(Context, Bundle, PrepareCallback)} or {@code present(Activity, Bundle)}.
 *
 * @param requestCode The request code used to start the activity
 * @param resultCode  The result code returned by the activity
 * @param data        The data returned by the activity
 * @return The notification card result of the activity if it exists, or null if it does not.
 *///  ww  w  . j  a v  a  2  s .  co  m
public static NotificationCardResult handleActivityResult(int requestCode, int resultCode,
        @Nullable Intent data) {
    if (requestCode != REQUEST_CODE) {
        return null;
    }
    if (resultCode != Activity.RESULT_OK || data == null) {
        return null;
    }

    return data.getParcelableExtra(CardActivity.EXTRA_NOTIFICATION_CARD_RESULT);
}

From source file:com.upnext.blekit.BLEKit.java

/**
 * Processes intent sent by BLEKitService.
 *
 * @param intent intent containing data/* w  ww. j  a v a 2s  . co m*/
 * @param ctx context
 */
protected static void processServiceEvent(Intent intent, Context ctx) {
    L.d(".");

    BLEKitClient clientAdd = intent.getParcelableExtra(Extra.EXTRA_CLIENT_ADD);
    if (clientAdd != null) {
        L.d(". add " + clientAdd.getPackageName());
        BeaconPreferences.addClient(ctx, clientAdd);
        return;
    }

    BLEKitClient clientRemove = intent.getParcelableExtra(Extra.EXTRA_CLIENT_REMOVE);
    if (clientRemove != null) {
        L.d(". remove " + clientRemove.getPackageName());
        BeaconPreferences.removeClient(ctx, clientRemove.getPackageName());
        return;
    }

    CurrentBeaconProximity currentBeaconProximity = intent
            .getParcelableExtra(Extra.EXTRA_CURRENT_BEACON_PROXIMITY);
    if (currentBeaconProximity != null) {
        L.d(". update proximity");
        mCurrentBeaconsStates.put(currentBeaconProximity.getBeaconId(), currentBeaconProximity.getProximity());
        if (mStateListener != null) {
            mStateListener.onCurrentBeaconProximityReceived(currentBeaconProximity.getBeaconId(),
                    currentBeaconProximity.getProximity());
        }
        return;
    }

    //fresh start, we do not have instance - app brought from the dead
    if (_bleKit == null) {
        L.d(". restart");
        restartBlekit(ctx);
        mEventToProcess = intent;
        return;
    }

    String event = intent.getStringExtra(Extra.EXTRA_BEACON_EVENT);
    if (event != null) {
        L.d(". event " + event);
        BeaconEvent beaconEvent = BeaconEvent.valueOf(event);
        String beaconId = intent.getStringExtra(Extra.EXTRA_BEACON_ID);

        mCurrentBeaconsStates.put(beaconId, Proximity.fromBeaconEvent(beaconEvent));

        for (Beacon beacon : getBeaconsFromZone(beaconId)) {
            _bleKit.processTriggersForBeacon(beacon, beaconEvent, ctx);
        }
    }

    mEventToProcess = null;
}

From source file:com.google.samples.apps.ledtoggler.LedActivity.java

private WeaveDevice getDeviceFromIntent(Intent intent) {
    return intent.getParcelableExtra(EXTRA_KEY_WEAVE_DEVICE);
}

From source file:com.qubling.sidekick.ui.module.ModuleViewActivity.java

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

    setContentView(R.layout.module_view);

    // Setup BugSense
    Util.setupBugSense(this);

    Intent intent = getIntent();
    Module module = (Module) intent.getParcelableExtra(EXTRA_MODULE);

    setTitle(module.getName());/*w ww  .  j ava  2 s .  com*/

    FragmentManager fragmentManager = getSupportFragmentManager();
    ModuleViewFragment fragment = (ModuleViewFragment) fragmentManager
            .findFragmentById(R.id.module_view_fragment);
    fragment.setModule(module);
}

From source file:com.mobizi.passwordmanager.AccountActivity.java

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

    Intent i = getIntent();
    Account account = (Account) i.getParcelableExtra("ACCOUNT");
    AccountType type = account == null ? (AccountType) i.getSerializableExtra("TYPE")
            : account.getAccountType();//from  w w  w.  ja va  2s  .c  om

    if (savedInstanceState == null) {
        displayFrag = AccountFragmentFactory.getAccountFragment(type);
        displayFrag.setAccount(account);
        FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
        ft.replace(R.id.content_frame, displayFrag, type.toString());
        ft.commit();
    }
}

From source file:com.google.android.gm.contentprovidertest.LabelDetailsActivity.java

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

    setContentView(R.layout.main);//from   ww  w  .j  a  va 2s. c om

    final Intent intent = getIntent();

    mLabelUri = (Uri) intent.getParcelableExtra(LABEL_URI_EXTRA);
}

From source file:com.example.android.directboot.alarms.AlarmIntentService.java

@Override
protected void onHandleIntent(Intent intent) {
    Context context = getApplicationContext();
    Alarm alarm = intent.getParcelableExtra(ALARM_KEY);

    NotificationManager notificationManager = context.getSystemService(NotificationManager.class);
    NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
            .setSmallIcon(R.drawable.ic_fbe_notification).setCategory(Notification.CATEGORY_ALARM)
            .setSound(Settings.System.DEFAULT_ALARM_ALERT_URI)
            .setContentTitle(context.getString(R.string.alarm_went_off, alarm.hour, alarm.minute));
    notificationManager.notify(alarm.id, builder.build());

    AlarmStorage alarmStorage = new AlarmStorage(context);
    alarmStorage.deleteAlarm(alarm);/*from ww  w .  j a  v  a2 s  .co m*/
    Intent wentOffIntent = new Intent(ALARM_WENT_OFF_ACTION);
    wentOffIntent.putExtra(ALARM_KEY, alarm);
    LocalBroadcastManager.getInstance(context).sendBroadcast(wentOffIntent);
}

From source file:com.example.gmailapptest.contentprovidertest.LabelDetailsActivity.java

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

    setContentView(R.layout.activity_main);

    final Intent intent = getIntent();

    mLabelUri = (Uri) intent.getParcelableExtra(LABEL_URI_EXTRA);
}

From source file:com.example.ami1.LabelDetailsActivity.java

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

    setContentView(R.layout.check);//from  w w  w. jav  a  2  s  . co m

    final Intent intent = getIntent();

    mLabelUri = (Uri) intent.getParcelableExtra(LABEL_URI_EXTRA);
}

From source file:anakiou.com.picontrol.service.EventLogIntentService.java

@Override
protected void onHandleIntent(Intent intent) {

    receiver = intent.getParcelableExtra(Constants.RECEIVER);

    if (!networkService.isNetworkAvailableAndConnected()) {

        deliverResultToReceiver(Constants.FAILURE_RESULT);

        return;//w w  w  .  j  a va 2  s .  c  o  m
    }

    int operationType = intent.getIntExtra(Constants.EXTRA_OPERATION_TYPE, 0);

    switch (operationType) {
    case Constants.OP_EVENT_LOG_GET_ALL:
        handleGetAll(intent);
        break;
    case Constants.OP_EVENT_LOG_GET:
        handleGet(intent);
        break;
    case Constants.OP_EVENT_LOG_COUNT:
        handleCount(intent);
    default:
    }
}