Summary: Ctors | Methods | Inherited Methods | [Expand All]
public static class

# SessionsApi.ViewIntentBuilder

extends Object

java.lang.Object
↳ | com.google.android.gms.fitness.SessionsApi.ViewIntentBuilder

## Class Overview

Builder of intents to view sessions stored in Google Fit. This intent can be used when the application wants to display a more detailed view of a particular session. Apps that can display sessions (such as the app that inserted the session) can register for the given intent.

If the application which inserted the session is installed on the device, it'll be preferred to handle the intent. This behavior can be overridden by `setPreferredApplication(String)`.

The session view intent has the following attributes:

- action is set to `ACTION_VIEW`
- type is `MIME_TYPE_PREFIX` followed by the activity for the session. For example, `vnd.google.fitness.session/running` would represent a running session.
- extras containing the session

An application that would like to handle Session view intents should create an activity and add an intent filter to its manifest file. Here's an example of an activity that can display biking and running sessions:

     <activity android:name=".ViewSessionActivity" android:exported="true">
        <intent-filter>
          <action android:name="vnd.google.fitness.VIEW" />
          <data android:mimeType="vnd.google.fitness.session/biking" />
          <data android:mimeType="vnd.google.fitness.session/running" />
       </intent-filter>
     </activity>

In addition, if the application is able to show sessions from other apps, it can add the `CATEGORY_DEFAULT` to the intent filter, as follows:

          <category android:name="android.intent.category.DEFAULT" />

## Summary

Public Constructors
| SessionsApi.ViewIntentBuilder(Context context)

Public Methods
Intent | build() Returns the built intent, which can be used with `startActivity(Intent)` to launch the desired Fitness activity.
SessionsApi.ViewIntentBuilder | setPreferredApplication(String packageName) Sets a preferred application to use for this intent.
SessionsApi.ViewIntentBuilder | setSession(Session session) Sets the session to display data for.

[Expand] Inherited Methods
From class java.lang.Object
Object | clone()
boolean | equals(Object arg0)
void | finalize()
final Class<?> | getClass()
int | hashCode()
final void | notify()
final void | notifyAll()
String | toString()
final void | wait(long arg0, int arg1)
final void | wait(long arg0)
final void | wait()

## Public Constructors

#### public SessionsApi.ViewIntentBuilder (Context context)

## Public Methods

#### public Intent build ()

Returns the built intent, which can be used with `startActivity(Intent)` to launch the desired Fitness activity.

##### Throws

IllegalStateException | if not enough data has been passed into the Builder to build a valid intent.

#### public SessionsApi.ViewIntentBuilder setPreferredApplication (String packageName)

Sets a preferred application to use for this intent. If the given app is installed and able to handle this intent, an explicit intent will be returned.

By default, the intent will attempt to use the application which inserted the session. Use this method only to override that behavior.

##### Parameters

packageName | the package name for the application to prefer for the intent, or `null` to not prefer any application

##### Returns

- this builder, for chaining

#### public SessionsApi.ViewIntentBuilder setSession (Session session)

Sets the session to display data for. A specific session must be set.

##### Parameters

session | the specific session to show data for

##### Returns

- this builder, for chaining