Reputation: 325
I'd like to add tracking for my android app for event such save/open... code like this:
layoutShow.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//handle click
//TODO:
DataLayer dataLayer = TagManager.getInstance(this).getDataLayer();
dataLayer.push(DataLayer.mapOf("event","clickButton","lable","save")
}
});
but I got error:The method getInstance(Context) in the type TagManager is not applicable for the arguments (new View.OnClickListener(){})
How to fix this?
Thanks
Upvotes: 0
Views: 1191
Reputation: 4069
instead of TagManager.getInstance(this)
use
TagManager.getInstance(MyActivity.this)
if you are in an activity,
or TagManager.getInstance(getActivity())
if you are in a Fragment.
because "this" here represent the listener you are in.
Upvotes: 3