Android Open Source - Tip_Calculator Activity Preferences






From Project

Back to project page Tip_Calculator.

License

The source code is released under:

Apache License

If you think the Android project Tip_Calculator 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.collinguarino.tipcalculator;
/*from   w  ww  .j  a  v a  2 s .  co  m*/
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.view.View;
import android.widget.ImageButton;

public class ActivityPreferences extends PreferenceActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        addPreferencesFromResource(R.layout.activity_preferences);
        setContentView(R.layout.fragment_preferences_header); // uses the listview in custom_preferences as the preferenceresource

        ImageButton share = (ImageButton) findViewById(R.id.share);
        share.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {

                Intent sharingIntent = new Intent(Intent.ACTION_SEND);
                sharingIntent.setType("text/plain");
                String shareBody = "Fast Tip Calculator app: https://play.google.com/store/apps/details?id=com.collinguarino.tipcalculator";
                sharingIntent.putExtra(Intent.EXTRA_TEXT, shareBody);
                startActivity(Intent.createChooser(sharingIntent, "Share To:"));

            }
        });

        ImageButton rate = (ImageButton) findViewById(R.id.rate);
        rate.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {

                try {
                    startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=com.collinguarino.tipcalculator")));
                } catch (android.content.ActivityNotFoundException anfe) {
                    startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=com.collinguarino.tipcalculator")));
                }

            }
        });
    }
}




Java Source Code List

com.collinguarino.tipcalculator.ActivityMain.java
com.collinguarino.tipcalculator.ActivityPreferences.java
com.collinguarino.tipcalculator.ApplicationTest.java
com.collinguarino.tipcalculator.CleanEditText.java
com.collinguarino.tipcalculator.TipCalculatorDashClock.java
com.collinguarino.tipcalculator.WidgetProvider.java