Книга: Beginning Android

Make an Intent

Make an Intent

As discussed in Chapter 1, Intents encapsulate a request, made to Android, for some activity or other Intent receiver to do something.

If the activity you intend to launch is one of your own, you may find it simplest to create an explicit Intent, naming the component you wish to launch. For example, from within your activity, you could create an Intent like this:

new Intent(this, HelpActivity.class);

This would stipulate that you wanted to launch the HelpActivity. This activity would need to be named in your AndroidManifest.xml file, though not necessarily with any Intent filter, since you are trying to request it directly.

Or you could put together an Intent for some Uri, requesting a particular action:

Uri uri = Uri.parse("geo:" + lat.toString() + "," + lon.toString());
Intent i = new Intent(Intent.ACTION_VIEW, uri);

Here, given that we have the latitude and longitude of some position (lat and lon, respectively) of type Double, we construct a geo scheme Uri and create an Intent requesting to view this Uri(ACTION_VIEW).

Оглавление книги

Оглавление статьи/книги

Генерация: 1.126. Запросов К БД/Cache: 3 / 0
поделиться
Вверх Вниз