Android Open Source - GADemo Messages Activity






From Project

Back to project page GADemo.

License

The source code is released under:

GNU General Public License

If you think the Android project GADemo 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.pdro.gademo;
/* w w w. j a va  2s  .  c  om*/


import android.annotation.SuppressLint;
import android.app.ActionBar;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.google.android.gms.analytics.GoogleAnalytics;
import com.google.android.gms.analytics.HitBuilders;
import com.google.android.gms.analytics.Logger;
import com.google.android.gms.analytics.Tracker;


@SuppressLint("NewApi") public class MessagesActivity extends Activity {

    private final String PROPERTY_ID = getString(R.string.gaProperty); // for GA
    private final int DISPATCH_PERIOD = 5;
    private Tracker tracker;
    private FactBook mFactBook = new FactBook();
    private ColorWheel mColorWheel = new ColorWheel();
    private final String screenName = "Message Screen";

    @Override
    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_messages);

        // Enabling Up / Back navigation
        ActionBar actionBar = getActionBar();
        actionBar.setDisplayHomeAsUpEnabled(true);

        // tracker code
        tracker = GoogleAnalytics.getInstance(this).newTracker(PROPERTY_ID);
        tracker.setScreenName(screenName);

        GoogleAnalytics.getInstance(this).setLocalDispatchPeriod(DISPATCH_PERIOD);
        GoogleAnalytics.getInstance(this).getLogger().setLogLevel(Logger.LogLevel.VERBOSE);

        tracker.send(new HitBuilders.AppViewBuilder().build());

        // define the buttons
        final TextView factLabel = (TextView) findViewById(R.id.factTextView);
        final Button showFactButton = (Button) findViewById(R.id.showFactButton);
        final RelativeLayout messageScreenLayout = (RelativeLayout) findViewById(R.id.messageScreenLayout);

        // Update the label with our dynamic fact
        String fact = mFactBook.getFact();
        factLabel.setText(fact);

        int color = mColorWheel.getColor();
        messageScreenLayout.setBackgroundColor(color);
        showFactButton.setTextColor(color);

        // Button Listener for Back to main
        showFactButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                Intent intent = new Intent(MessagesActivity.this, MainActivity.class);
                startActivity(intent);

            }
        });
    }
}




Java Source Code List

com.pdro.gademo.BuildConfig.java
com.pdro.gademo.ColorWheel.java
com.pdro.gademo.FactBook.java
com.pdro.gademo.MainActivity.java
com.pdro.gademo.MessagesActivity.java
com.pdro.gademo.SplashScreen.java