Example usage for android.content Intent getStringExtra

List of usage examples for android.content Intent getStringExtra

Introduction

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

Prototype

public String getStringExtra(String name) 

Source Link

Document

Retrieve extended data from the intent.

Usage

From source file:com.google.android.gcm.demo.app.GCMIntentService.java

@Override
protected void onMessage(Context context, Intent intent) {
    String api = intent.getStringExtra("api");
    Log.i(TAG, "Received message: " + api);

    // get list of all mp3 files now
    AndroidHttpClient client = null;//from  w ww.j ava2s  . c o  m
    try {
        client = AndroidHttpClient.newInstance("Android");

        HttpGet httpGet = new HttpGet(api);
        HttpResponse response;
        try {
            response = client.execute(httpGet);
            String json = EntityUtils.toString(response.getEntity());
            JSONArray array = new JSONArray(json);
            ArrayList<String> urls = new ArrayList<String>();
            for (int i = 0; i < array.length(); ++i) {
                String mp3Link = array.getString(i);
                urls.add(mp3Link);
            }

            // start DownloadService
            Intent itent = new Intent(this, DownloadService.class);
            itent.putExtra(CommonUtilities.EXTRA_URLS, urls);
            startService(itent);
        } catch (IOException e) {
            e.printStackTrace();
        } catch (JSONException e) {
            e.printStackTrace();
        }

    } finally {
        if (client != null) {
            client.close();
        }
    }
}

From source file:com.google.developers.actions.debugger.CayleyActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    try {//w  w w  .j a  v a  2 s  .  c o  m
        getActionBar().setDisplayHomeAsUpEnabled(true);
    } catch (NullPointerException e) {
        e.printStackTrace();
    }
    setContentView(R.layout.activity_cayley);
    Intent intent = getIntent();
    intent.setAction(intent.getStringExtra(MainActivity.ACTION));
    intent.setComponent(null);
    mIntent = intent;
    mActionType = intent.getStringExtra(MainActivity.ACTION_TYPE);
    if (mActionType.equals("PLAY_ARTIST")) {
        mEditText = (EditText) findViewById(R.id.artist);
        mEditText.setVisibility(View.VISIBLE);
        mEditText.setText(getString(R.string.dual_core));
    } else {
        mEditText = (EditText) findViewById(R.id.genre);
        mEditText.setVisibility(View.VISIBLE);
        mEditText.setText(getString(R.string.nerdcore));
    }
}

From source file:cn.count.easydrive366.CarRegistrationEditActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.modules_edit_carregistration_activity);
    this.setupLeftButton();
    Intent intent = this.getIntent();
    String data = intent.getStringExtra("data");
    try {/*from www.  j av  a  2 s.co m*/
        JSONObject json = new JSONObject(data);
        initView(json);
    } catch (JSONException e) {
        log(e);
    }

}

From source file:net.olejon.mdapp.LvhCategoriesActivity.java

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

    // Transition
    overridePendingTransition(R.anim.slide_in_from_right, R.anim.slide_out_to_left);

    // Intent//from   w  w w .j  ava  2s .com
    final Intent intent = getIntent();

    final String categoryColor = intent.getStringExtra("color");
    final String categoryIcon = intent.getStringExtra("icon");
    final String categoryTitle = intent.getStringExtra("title");

    JSONArray subcategories;

    try {
        subcategories = new JSONArray(intent.getStringExtra("subcategories"));
    } catch (Exception e) {
        subcategories = new JSONArray();

        Log.e("LvhCategoriesActivity", Log.getStackTraceString(e));
    }

    // Layout
    setContentView(R.layout.activity_lvh_categories);

    // Toolbar
    final Toolbar toolbar = (Toolbar) findViewById(R.id.lvh_categories_toolbar);
    toolbar.setTitle(categoryTitle);

    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    // Recycler view
    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.lvh_categories_cards);

    recyclerView.setHasFixedSize(true);
    recyclerView.setLayoutManager(new LinearLayoutManager(mContext));

    if (mTools.isTablet()) {
        int spanCount = (subcategories.length() == 1) ? 1 : 2;

        recyclerView.setLayoutManager(
                new StaggeredGridLayoutManager(spanCount, StaggeredGridLayoutManager.VERTICAL));
    }

    // Get categories
    recyclerView.setAdapter(new LvhCategoriesAdapter(mContext, subcategories, categoryColor, categoryIcon));
}

From source file:com.example.administrator.myapplication2._4_Detail.LeftFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout._2_fragment_main_dummy, container, false);

    Intent myIntent = getActivity().getIntent();
    if (myIntent != null) {
        seq = myIntent.getStringExtra("seq");
    }//from  w  ww . j  a v  a  2s.  co m

    tvHeart = (TextView) rootView.findViewById(R.id.tvHeart);
    tvDistance = (TextView) rootView.findViewById(R.id.tvDistance);
    tvCalorie = (TextView) rootView.findViewById(R.id.tvCalorie);
    tvWeight = (TextView) rootView.findViewById(R.id.tvWeight);
    ;
    tvRuntime = (TextView) rootView.findViewById(R.id.tvRuntime);

    SharedPreferences myPrefs = this.getActivity().getSharedPreferences("login", Context.MODE_PRIVATE);
    if ((myPrefs != null) && (myPrefs.contains("id"))) {
        id = myPrefs.getString("id", "");
        Log.i("logintest", id.toString());
    }

    getRecentData();

    return rootView;
}

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  av  a  2 s. co m

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

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

private void getBook(Intent intent) {
    String category = intent.getStringExtra(CATEGORY);
    String book = intent.getStringExtra(BOOK_NAME);
    File categoryDir = getCategoryDir(category);

    File pdfFile = new File(categoryDir, book);
    if (!pdfFile.exists()) {
        fetch(category, pdfFile);/*w ww.  j a  v a 2 s .c  om*/
    }

    sendResult(intent.getAction(), category, pdfFile);
}

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

private void deleteBook(Intent intent) {
    String category = intent.getStringExtra(CATEGORY);
    String book = intent.getStringExtra(BOOK_NAME);
    File categoryDir = getCategoryDir(category);

    File pdfFile = new File(categoryDir, book);
    if (pdfFile.exists()) {
        pdfFile.delete();//from   ww  w. ja  v a2 s.  c  o m
    }

    sendResult(ACTION_CHECK_BOOKS, category, pdfFile);
}

From source file:com.remdo.app.WebViewActivity.java

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.activity_web_view);

    // Get the uri from the intent
    Intent intent = getIntent();
    String uriToDisplay = intent.getStringExtra("DEVICE_URL");
    String usr = intent.getStringExtra("DEVICE_USER");
    String pwd = intent.getStringExtra("DEVICE_PASSWORD");
    Integer odTypeId = intent.getIntExtra("DEVICE_ODTYPEID", -1);

    if (odTypeId == 1)//ODNetWork    
    {/*www. j a  v a  2 s .c om*/
        if (!uriToDisplay.contains("cgi-bin/od.cgi")) {
            uriToDisplay = uriToDisplay.concat("/cgi-bin/od.cgi");
        }

        //initialize WebView
        webView = (WebView) findViewById(R.id.webView1);
        //we should define a webview client to get user navigation inside our webview otherwise 
        //defaul behaviour will open a webbrowser on first click
        webView.setWebViewClient(new WebViewClient());

        try {

            byte[] post = EncodingUtils.getBytes("USERNAME=" + usr + "&PASSWORD=" + pwd, "BASE64");
            webView.postUrl(uriToDisplay, post);

        } catch (Exception e) {
            String message = e.getMessage();
        }
    } else//ODControl
    {
        webView = (WebView) findViewById(R.id.webView1);

        webView.setHttpAuthUsernamePassword(uriToDisplay, "/", "user@opendomo.com", "opendomo");
        webView.setWebChromeClient(new WebChromeClient());
        webView.setWebViewClient(new MyWebViewClient());
        webView.getSettings().setJavaScriptEnabled(true);
        webView.loadUrl("http://local.opendomo.com");

    }

}

From source file:com.nostra13.example.universalimageloader.ImageGridActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Intent i = getIntent();
    imageUrlString = i.getStringExtra("imagejsonurl");
    setContentView(R.layout.ac_image_grid);
    tmp_ImageJsonArray = new ArrayList<String>();
    new ImageJsonTask().execute();

}