Example usage for android.content Intent getStringArrayListExtra

List of usage examples for android.content Intent getStringArrayListExtra

Introduction

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

Prototype

public ArrayList<String> getStringArrayListExtra(String name) 

Source Link

Document

Retrieve extended data from the intent.

Usage

From source file:me.reed.album.DetailActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_detail);
    Intent intent = getIntent();
    paths = intent.getStringArrayListExtra(PICTURES);
    position = intent.getIntExtra(POSITION, -1);
    if (paths == null || position == -1) {
        finish();/*w w w .  ja v  a 2s. co  m*/
    }
    fragments = new ArrayList<>();
    for (String path : paths) {
        Fragment fragment = new DetailFragment();
        Bundle bundle = new Bundle();
        bundle.putString(DetailFragment.PICTURE_PATH, path);
        fragment.setArguments(bundle);
        fragments.add(fragment);
    }
    initView();

}

From source file:com.app.ui.PictureSlideActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_pictureslide);

    Intent intent = this.getIntent();
    if (intent == null) {
        return;//from w  w w .ja  va  2s. c  o m
    }
    List<String> items = intent.getStringArrayListExtra("data");

    int index = intent.getIntExtra("index", 0);
    if (items == null) {
        Log.v(TAG, "null++++");
        finish();
        return;
    } else {
        for (int i = 0; i < items.size(); i++) {
            Log.v(TAG, "path:" + items.get(i));
        }
    }

    ViewPagerAdapter pagerAdapter = new ViewPagerAdapter(this, items);

    mViewPager = (ViewPager) findViewById(R.id.viewer);
    mViewPager.setOffscreenPageLimit(3);
    mViewPager.setPageMargin(10);
    mViewPager.setAdapter(pagerAdapter);
    mViewPager.setCurrentItem(index);

    mPresenter = new PictureSlidePresenter(this);
}

From source file:com.facebook.reflection.SwipeActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Create the adapter that will return a fragment for each of the three primary sections
    // of the app.
    mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager());

    Intent intent = getIntent();
    result = intent.getStringArrayListExtra("result");
    // Set up the action bar.
    final ActionBar actionBar = getActionBar();

    // Specify that the Home/Up button should not be enabled, since there is no hierarchical
    // parent./*from w ww  .j a  v  a2  s  .  c om*/
    actionBar.setHomeButtonEnabled(false);

    // Set up the ViewPager, attaching the adapter and setting up a listener for when the
    // user swipes between sections.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mAppSectionsPagerAdapter.setResult(result);
    mViewPager.setAdapter(mAppSectionsPagerAdapter);
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {

        }
    });

    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < mAppSectionsPagerAdapter.getCount(); i++) {
        // Create a tab with text corresponding to the page title defined by the adapter.
        // Also specify this Activity object, which implements the TabListener interface, as the
        // listener for when this tab is selected.
        actionBar.addTab(
                actionBar.newTab().setText(mAppSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }
}

From source file:MainActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == REQUEST_SPEECH && resultCode == RESULT_OK && data != null) {
        ArrayList<String> result = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);

        TextView textView = (TextView) findViewById(R.id.textView);
        if (result.size() > 0) {
            textView.setText("");
            for (String item : result) {
                textView.append(item + "\n");
            }/* w w w . jav a 2 s. com*/
        }
    }
}

From source file:com.uphyca.android.nagiharae.MainActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == REQUEST_CODE && resultCode == RESULT_OK) {
        ArrayList<String> results = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);

        if (results.size() > 0) {
            if (results.get(0).equals("????")) {
                sendCommandFlag = true;/*from  w ww. j  a va2s .  c  o m*/
                try {
                    mSocketClientFragment.sendCommand("NAGIHARAE");
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            Toast.makeText(this, results.get(0), Toast.LENGTH_SHORT).show();
        } else {
            Log.d(TAG, "result.size() = 0");
        }
    } else {
        Log.d(TAG, requestCode + ", " + requestCode);
    }
}

From source file:dev.drsoran.moloko.activities.TaskEditActivity.java

@Override
protected void onActivityResult(int req, int result, Intent data) {
    if (req == REQ_DEFAULT) {
        if (result == RESULT_OK) {
            onTagsChanged(data.getStringArrayListExtra(Intents.Extras.KEY_TAGS));
        }// w  ww  . j a v  a2s  .c  om
    }

    super.onActivityResult(req, result, data);
}

From source file:es.uma.lcc.lockpic.SelectorActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == RESULT_OK && data != null) {
        mDrawView.setRectanglePermissions(data.getStringArrayListExtra("accounts"), requestCode);
    }//from  w  w  w  .  ja v  a2 s .com
}

From source file:com.nadmm.airports.library.LibraryService.java

private void checkBooks(Intent intent) {
    String category = intent.getStringExtra(CATEGORY);
    ArrayList<String> books = intent.getStringArrayListExtra(BOOK_NAMES);

    cleanupBooks(category, books);/* w w  w .  j  a  v a2 s .  c o m*/

    File categoryDir = getCategoryDir(category);
    for (String book : books) {
        File pdfFile = new File(categoryDir, book);
        sendResult(intent.getAction(), category, pdfFile);
    }
}

From source file:me.willowcheng.makerthings.core.OpenHABVoiceService.java

private String extractVoiceCommand(Intent data) {
    String voiceCommand = "";
    List<String> textMatchList = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
    if (!textMatchList.isEmpty()) {
        voiceCommand = textMatchList.get(0);
    }/*from  w  w  w . j  a  v  a 2  s . c  o  m*/
    Log.i(TAG, "Recognized text: " + voiceCommand);
    showToast(getString(R.string.info_voice_recognized_text, voiceCommand));
    return voiceCommand;
}

From source file:com.digitallifelab.environmentmonitor.ImageDetailActivity.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override//w  ww . ja v a  2 s.  c o m
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.image_detail_pager);

    // Fetch screen height and width, to use as our max size when loading images as this
    // activity runs full screen
    final DisplayMetrics displayMetrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
    final int height = displayMetrics.heightPixels;
    final int width = displayMetrics.widthPixels;

    Intent data = getIntent();
    if (data.hasExtra(IMAGES_ARRAY)) {
        imagesList = data.getStringArrayListExtra(IMAGES_ARRAY);
    } else {
        imagesList = new ArrayList<String>();
    }

    // Set up ViewPager and backing adapter
    mAdapter = new ImagePagerAdapter(getSupportFragmentManager(), imagesList.size());
    mPager = (ViewPager) findViewById(R.id.pager);
    mPager.setAdapter(mAdapter);
    mPager.setPageMargin((int) getResources().getDimension(R.dimen.activity_horizontal_margin));
    mPager.setOffscreenPageLimit(2);

    // Set up activity to go full screen
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);

    // Enable some additional newer visibility and ActionBar features to create a more
    // immersive photo viewing experience
    if (Utility.hasHoneycomb()) {
        //setSupportActionBar(null);
        final ActionBar actionBar = getSupportActionBar();

        // Hide title text and set home as up
        actionBar.setDisplayShowTitleEnabled(false);
        actionBar.setDisplayHomeAsUpEnabled(true);

        // Hide and show the ActionBar as the visibility changes
        mPager.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
            @Override
            public void onSystemUiVisibilityChange(int vis) {
                if ((vis & View.SYSTEM_UI_FLAG_LOW_PROFILE) != 0) {
                    actionBar.hide();
                } else {
                    actionBar.show();
                }
            }
        });

        // Start low profile mode and hide ActionBar
        mPager.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
        actionBar.hide();
    }

    // Set the current item based on the extra passed in to this activity
    final int extraCurrentItem = getIntent().getIntExtra(EXTRA_IMAGE, -1);
    if (extraCurrentItem != -1) {
        mPager.setCurrentItem(extraCurrentItem);
    }
}