• /
  • Log in
  • Free account

startInteraction (Android SDK API)

Syntax

NewRelic.startInteraction(string $interactionName)

Create an interaction to instrument a method in your Android app code.

Requirements

Compatible with all agent versions.

Description

Use startInteraction() on a method in your Android app code to create a New Relic-monitored interaction:

  1. Import the New Relic SDK API for Android:

    import com.newrelic.agent.android.NewRelic;
  2. Start an interaction trace on a method in your app code and give it a name:

    NewRelic.startInteraction(String $interactionName);

To name an interaction that already exists and is already being tracked, see setInteractionName().

For general info on using the New Relic Android SDK API, see the usage guide.

Parameters

Parameter

Description

$actionName

string

Required. The name you want to give to the interaction.

Return values

Returns an interaction ID numberwhich can be used for ending the interaction at a certain point.

Examples

Start interaction on button press

An example of starting to track an interaction named RefreshContacts:

public class MainActivity extends Activity {
...
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_refresh:
NewRelic.startInteraction("RefreshContacts");
……
return true;
default:
return super.onOptionsItemSelected(item);
}
}
...
}
Create issueEdit page
Copyright © 2022 New Relic Inc.