Android Open Source - ramp_up_android Intents Started Activity






From Project

Back to project page ramp_up_android.

License

The source code is released under:

Apache License

If you think the Android project ramp_up_android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.macadamian;
//from ww  w . j  av  a  2 s.  c o  m
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

public class IntentsStartedActivity extends Activity {
    View.OnClickListener _click_listener = new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish_with_result();
            }
        };

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

        setContentView(R.layout.intents_started);
        findViewById(R.id.intents_started_action_confirm).setOnClickListener(_click_listener);
        ((TextView) findViewById(R.id.intents_started_provided_option)).setText(format_option());
    }

    private void finish_with_result() {
        setResult(Activity.RESULT_OK, get_result());
        finish();
    }

    private String format_option() {
        String rv = "Received option: ";

        Intent i = getIntent();
        switch (i.getIntExtra(IntentsActivity.EXTRA_OPTION, -1)) {
            case 0:
                rv += "A";
                break;
            case 1:
                rv += "B";
                break;
        }

        return rv;
    }

    private Intent get_result() {
        Intent rv = new Intent(IntentsActivity.ACTION_RESULT);
        Intent i = getIntent();
        switch (i.getIntExtra(IntentsActivity.EXTRA_OPTION, -1)) {
            case 0:
                rv.putExtra(IntentsActivity.EXTRA_RESULT, "option a");
                break;
            case 1:
                rv.putExtra(IntentsActivity.EXTRA_RESULT, "option b");
                break;
        }
        return rv;
    }
}




Java Source Code List

com.macadamian.ActionBarExampleActivity.java
com.macadamian.ActionsActivity.java
com.macadamian.BasicUserInterfaceActivity.java
com.macadamian.BroadcastsActivity.java
com.macadamian.CursorAdapterActivity.java
com.macadamian.DataExamplesFragment.java
com.macadamian.ExamplePreferenceFragment.java
com.macadamian.ExamplesSelectionActivity.java
com.macadamian.ExecutionControlExamplesFragment.java
com.macadamian.FragmentsActivity.java
com.macadamian.InAppBillingActivity.java
com.macadamian.IntentsActivity.java
com.macadamian.IntentsStartedActivity.java
com.macadamian.SimpleListAdapterActivity.java
com.macadamian.SystemExamplesFragment.java
com.macadamian.UserInterfaceExamplesFragment.java
com.macadamian.ViewPagerActivity.java
com.macadamian.billing.Base64DecoderException.java
com.macadamian.billing.Base64.java
com.macadamian.billing.IabException.java
com.macadamian.billing.IabHelper.java
com.macadamian.billing.IabResult.java
com.macadamian.billing.Inventory.java
com.macadamian.billing.Purchase.java
com.macadamian.billing.Security.java
com.macadamian.billing.SkuDetails.java