Question

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

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top