Android Open Source - tapad-android-sdk Main Activity






From Project

Back to project page tapad-android-sdk.

License

The source code is released under:

MIT License

If you think the Android project tapad-android-sdk listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.tapad.sample;
/*from ww w  .  j  a v  a 2 s  .c om*/
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import com.tapad.adserving.AdServing;
import com.tapad.tracking.Tracking;

public class MainActivity extends Activity {

    private TextView deviceId;
    private TextView typedDeviceId;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        // If your app has only one Activity or can guarantee that this one is always started before any other
        // Activities, then you can initialize the SDKs here instead of declaring an Application
        // AdServing.init(this); // if you are using the AdServing SDK or AdServing + EventTracking SDKs
        // Tracking.init(this); // if you are only using the EventTracking SDK

        deviceId = (TextView) findViewById(R.id.device_id);
        typedDeviceId = (TextView) findViewById(R.id.typed_device_id);
        updateDeviceId();

        Button custom = (Button) findViewById(R.id.custom_event);
        custom.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                Tracking.get().onEvent("custom1");
            }
        });

        Button adMarkup = (Button) findViewById(R.id.pull_ad_markup);
        adMarkup.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(final View view) {
                startActivity(new Intent(MainActivity.this, ManualMarkupActivity.class));
            }
        });

        Button managedView = (Button) findViewById(R.id.managed_ad_view);
        managedView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(MainActivity.this, AdViewActivity.class));
            }
        });

        Button optInOut = (Button) findViewById(R.id.opt_in_out);
        optInOut.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (Tracking.isOptedOut())
                    Tracking.optIn(MainActivity.this);
                else
                    Tracking.optOut(MainActivity.this);

                updateDeviceId();
            }
        });
    }

    private void updateDeviceId() {
        deviceId.setText("Device ID: " + Tracking.getDeviceId().get());
        typedDeviceId.setText("Typed Device ID(s): " + Tracking.getDeviceId().getTypedIds());
    }
}




Java Source Code List

com.tapad.adserving.AdRequestDispatcher.java
com.tapad.adserving.AdRequest.java
com.tapad.adserving.AdResource.java
com.tapad.adserving.AdResponse.java
com.tapad.adserving.AdServingServiceImpl.java
com.tapad.adserving.AdServingService.java
com.tapad.adserving.AdServing.java
com.tapad.adserving.AdSize.java
com.tapad.adserving.ui.AdView.java
com.tapad.sample.AdViewActivity.java
com.tapad.sample.MainActivity.java
com.tapad.sample.MainApplication.java
com.tapad.sample.ManualMarkupActivity.java
com.tapad.sample.SampleConstants.java
com.tapad.tracking.DeviceIdentifier.java
com.tapad.tracking.DeviceInfo.java
com.tapad.tracking.EventDispatcher.java
com.tapad.tracking.EventResource.java
com.tapad.tracking.Event.java
com.tapad.tracking.InstallReferrerReceiver.java
com.tapad.tracking.TrackingServiceImpl.java
com.tapad.tracking.TrackingService.java
com.tapad.tracking.Tracking.java
com.tapad.tracking.deviceidentification.AndroidId.java
com.tapad.tracking.deviceidentification.IdentifierSourceAggregator.java
com.tapad.tracking.deviceidentification.IdentifierSource.java
com.tapad.tracking.deviceidentification.PhoneId.java
com.tapad.tracking.deviceidentification.TypedIdentifier.java
com.tapad.tracking.deviceidentification.WifiMac.java
com.tapad.util.DigestUtil.java
com.tapad.util.HttpClientUtil.java
com.tapad.util.IoUtil.java
com.tapad.util.Logging.java