Manual Programación Android

Page 57

andbook - Android Programming

Picture 21 Using Eclipse to find methods to override

So now we can simply switch on the requestCode and create another Intent to do the Google-search. /* Check which SubActivity returned. * (Here we have only one.) */ switch(requestCode){ case MYSECONDACTIVITY_REQUESTCODE: /* Create a new Intent to * show the Google-Search Page * with the keyword returned. */ Intent webIntent = new Intent( android.content.Intent.VIEW_ACTION, Uri.parse("http://www.google.com/search?q=" + data)); startActivity(webIntent); break; }

As you probably have recognized this time we are creating the Intent another way. Last time we said like: “We want to start XYZ.class“, but this time we describe what we want to get done. We want to VIEW a URI (Uniform Resource Indicator), which can be constructed by using i.e. Uri.fromParts(…). Our Application is now capable of starting a (Sub)Activity, grabbing its results and launching the Browser using an Intent. But how to pass data to a (Sub)Activity?

57 powered by anddev.org


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.