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:
Import the New Relic SDK API for Android:
import com.newrelic.agent.android.NewRelic;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 |
---|---|
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); } } ...}