Example usage for android.content Intent getSerializableExtra

List of usage examples for android.content Intent getSerializableExtra

Introduction

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

Prototype

public Serializable getSerializableExtra(String name) 

Source Link

Document

Retrieve extended data from the intent.

Usage

From source file:eu.power_switch.gui.activity.ScenesActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    // set Theme before anything else in onCreate
    ThemeHelper.applyTheme(this);

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_scenes);

    // allow always-on screen
    setAmbientEnabled();/* w w w  .j  a  v a 2 s  .  c  o m*/

    dataApiHandler = new DataApiHandler(getApplicationContext());

    // BroadcastReceiver to get notifications from background service if room data has changed
    broadcastReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            Log.d("MainActivity", "received intent: " + intent.getAction());

            ArrayList<Scene> scenes = (ArrayList<Scene>) intent
                    .getSerializableExtra(ListenerService.SCENE_DATA);
            replaceSceneList(scenes);

            refreshUI();
        }
    };

    final WatchViewStub stub = (WatchViewStub) findViewById(R.id.watch_view_stub);
    stub.setOnLayoutInflatedListener(new WatchViewStub.OnLayoutInflatedListener() {
        @Override
        public void onLayoutInflated(WatchViewStub stub) {

            relativeLayoutAmbientMode = (RelativeLayout) findViewById(R.id.relativeLayout_ambientMode);

            scenesRecyclerView = (RecyclerView) findViewById(R.id.scenes_recyclerView);
            sceneRecyclerViewAdapter = new SceneRecyclerViewAdapter(stub.getContext(), scenesRecyclerView,
                    sceneList, dataApiHandler);
            scenesRecyclerView.setAdapter(sceneRecyclerViewAdapter);

            SnappingLinearLayoutManager layoutManager = new SnappingLinearLayoutManager(getApplicationContext(),
                    LinearLayoutManager.VERTICAL, false);
            scenesRecyclerView.setLayoutManager(layoutManager);

        }
    });
}

From source file:random.taiga.chat.truelecter.randomchat.ChatActivity.java

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

    Button btnSend = (Button) findViewById(R.id.btnSend);
    inputMsg = (EditText) findViewById(R.id.inputMsg);
    ListView listViewMessages = (ListView) findViewById(R.id.list_view_messages);

    // Getting the person name from previous screen
    Intent i = getIntent();
    User u = User.setInstance((User) i.getSerializableExtra("user"));

    btnSend.setOnClickListener(new View.OnClickListener() {

        @Override//from  w w w.  j av  a2 s .  c om
        public void onClick(View v) {
            if (!ChatSendThread.getInstance().canSend()) {
                showToast(" ?  ??");
                return;
            }

            // Sending message to server
            ChatSendThread.getInstance().send(inputMsg.getText().toString());

            // Clearing the input filed once message was sent
            inputMsg.setText("");
        }
    });

    listMessages = new ArrayList<>();

    adapter = new MessagesListAdapter(this, listMessages);
    listViewMessages.setAdapter(adapter);

    Chat c = Chat.getInstance();

    ChatUpdateThread ct = new ChatUpdateThread(c, new ChatUpdateThread.NewMessageHandler() {
        @Override
        public void processMessage(Message m) {
            appendMessage(m);
        }
    });
    ct.start();

    ChatSendThread cs = new ChatSendThread(c, u);
    cs.start();

    instance = this;

}

From source file:com.winsuk.pebbletype.WatchCommunication.java

@Override
public void onReceive(Context context, Intent intent) {
    if (ACTION_PEBBLE_RECEIVE.equals(intent.getAction())) {
        final UUID receivedUuid = (UUID) intent.getSerializableExtra("uuid");

        // Pebble-enabled apps are expected to be good citizens and only inspect broadcasts containing their UUID
        if (!PEBBLE_APP_UUID.equals(receivedUuid)) {
            return;
        }/*from   w  w w.jav a 2 s.com*/

        final int transactionId = intent.getIntExtra("transaction_id", -1);
        final String jsonData = intent.getStringExtra("msg_data");
        if (jsonData == null || jsonData.isEmpty()) {
            return;
        }

        try {
            final PebbleDictionary data = PebbleDictionary.fromJson(jsonData);
            receiveData(context, transactionId, data);
        } catch (JSONException e) {
            e.printStackTrace();
            return;
        }
    }

    if (ACTION_SMS_REPLY.equals(intent.getAction())) {
        boolean sent = getResultCode() == Activity.RESULT_OK;

        if (!sent)
            Log.w("com.winsuk.pebbletype", "Message failed to send. Result code: " + getResultCode());

        PebbleDictionary data = new PebbleDictionary();
        data.addUint8(sent ? KEY_MESSAGE_SENT : KEY_MESSAGE_NOT_SENT, (byte) 1);
        PebbleKit.sendDataToPebble(context, PEBBLE_APP_UUID, data);
    }
}

From source file:com.indragie.cmput301as1.ExpenseClaimListFragment.java

/**
 * Sets a expense claim at a specified position in the list model from a intent.
 * @param data The intent to get the expense claim from.
 *///from  w ww .j a  v a2 s . com
private void onEditExpenseResult(Intent data) {
    ExpenseClaim claim = (ExpenseClaim) data
            .getSerializableExtra(ExpenseClaimDetailActivity.EXTRA_EXPENSE_CLAIM);
    int position = data.getIntExtra(ExpenseClaimDetailActivity.EXTRA_EXPENSE_CLAIM_INDEX, -1);
    controller.set(position, claim);
}

From source file:com.microsoft.mimickeralarm.appcore.AlarmMainActivity.java

@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    UUID alarmId = (UUID) intent.getSerializableExtra(AlarmScheduler.ARGS_ALARM_ID);
    if (alarmId != null) {
        showAlarmSettingsFragment(alarmId.toString());
    }//from  w w  w.  j a v  a2 s  . com
}

From source file:com.duy.pascal.ui.activities.SplashScreenActivity.java

private void handleRunProgram(Intent data) {
    Intent runIntent = new Intent(this, ExecuteActivity.class);
    runIntent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
    Serializable file = data.getSerializableExtra(CompileManager.EXTRA_FILE);
    runIntent.putExtra(CompileManager.EXTRA_FILE, file);
    overridePendingTransition(0, 0);/*from w w w.ja v  a 2 s  .  c o  m*/
    startActivity(runIntent);
    finish();
}

From source file:com.example.android.aberdean.popularmoviesi.MovieDetails.java

/**
 * Assigns the appropriate values for the chosen movie.
 * @param savedInstanceState the previously saved state
 *///from   ww  w. j  a  v  a  2s .  co m
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.movie_details);

    mBackdrop = (ImageView) findViewById(R.id.iv_backdrop);
    mPosterThumb = (ImageView) findViewById(R.id.iv_poster_thumb);

    mSynopsis = (TextView) findViewById(R.id.tv_synopsis);
    mReleaseDate = (TextView) findViewById(R.id.tv_release_date);
    TextView mOriginalTitle = (TextView) findViewById(R.id.tv_title);
    mRating = (TextView) findViewById(R.id.tv_rating);

    Intent intent = getIntent();

    if (intent != null && intent.hasExtra("movieDetails")) {

        Resources res = getResources();

        ArrayList mChosenMovie = (ArrayList<?>) intent.getSerializableExtra("movieDetails");

        String posterUri = mChosenMovie.get(0).toString();
        String backdropUri = mChosenMovie.get(1).toString();
        setImage(posterUri, backdropUri);

        String synopsis = mChosenMovie.get(2).toString();
        mSynopsis.setText(synopsis);

        String releaseDate = mChosenMovie.get(3).toString();
        String release = String.format(res.getString(R.string.released), releaseDate);
        mReleaseDate.setText(release);

        String title = mChosenMovie.get(4).toString();
        mOriginalTitle.setText(title);

        String rating = mChosenMovie.get(5).toString();
        String rate = String.format(res.getString(R.string.rating), rating);
        mRating.setText(rate);
    }
}

From source file:com.indragie.cmput301as1.ExpenseClaimListFragment.java

/**
 * Filters the expense claims list based on the filter tags contained within
 * the intent.//w w w. j a  v a 2  s .c om
 * @param data The intent to get the filter tags from.
 */
@SuppressWarnings("unchecked")
private void onFilterTagsRequest(Intent data) {
    ArrayList<Tag> tags = (ArrayList<Tag>) data.getSerializableExtra(FilterTagsActivity.TAG_TO_FILTER);
    controller.filter(tags);
}

From source file:mx.itesm.logistics.crew_tracking.activity.VehicleListActivity.java

@Override
public void onResult(int requestCode, int resultCode, final Intent data) {
    if (resultCode != TargetListener.RESULT_OK)
        return;/*from   w  w  w .j a  va  2s . co m*/

    switch (requestCode) {
    case REQUEST_VEHICLE:
        Intent intent = new Intent();
        intent.putExtra(EXTRA_VEHICLE, data.getSerializableExtra(VehicleListFragment.EXTRA_VEHICLE));
        setResult(Activity.RESULT_OK, intent);
        finish();
        break;
    }
}