Android Open Source - ui-showcase-for-android About Activity






From Project

Back to project page ui-showcase-for-android.

License

The source code is released under:

Apache License

If you think the Android project ui-showcase-for-android 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.github.ksoichiro.uishowcase;
//from   w  ww . j a v  a  2  s . co m
import android.annotation.TargetApi;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.text.Html;
import android.view.MenuItem;
import android.widget.TextView;

/**
 * @author Soichiro Kashima
 */
public class AboutActivity extends ActionBarActivity {

    @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
    @Override
    protected void onCreate(final Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_about);

        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setHomeButtonEnabled(true);

        ((TextView) findViewById(R.id.version_name)).setText(getVersionName());
        ((TextView) findViewById(R.id.copyright)).setText(Html
                .fromHtml(getString(R.string.msg_copyright)));
    }

    @Override
    public boolean onOptionsItemSelected(final MenuItem menu) {
        if (menu.getItemId() == android.R.id.home) {
            finish();
            return true;
        }
        return false;
    }

    private String getVersionName() {
        final PackageManager manager = getPackageManager();
        String versionName;
        try {
            final PackageInfo info = manager.getPackageInfo(
                    getPackageName(),
                    PackageManager.GET_META_DATA);
            versionName = info.versionName;
        } catch (PackageManager.NameNotFoundException e) {
            versionName = "";
        }
        return versionName;
    }

}




Java Source Code List

com.github.ksoichiro.uishowcase.AboutActivity.java
com.github.ksoichiro.uishowcase.ApplicationTest.java
com.github.ksoichiro.uishowcase.CoachMarkActivity.java
com.github.ksoichiro.uishowcase.EmptyDataActivity.java
com.github.ksoichiro.uishowcase.MainActivity.java