Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.android.justjava;
- import android.content.Intent;
- import android.net.Uri;
- import android.os.Bundle;
- import android.support.v7.app.AppCompatActivity;
- import android.view.View;
- import android.widget.CheckBox;
- import android.widget.EditText;
- import android.widget.TextView;
- import java.text.NumberFormat;
- import static android.R.attr.value;
- import static android.R.id.checkbox;
- import static android.R.id.message;
- /**
- * This app displays an order form to order coffee.
- */
- public class MainActivity extends AppCompatActivity {
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- }
- int topping_price = 0;
- /**
- * This method is called when the order button is clicked.
- */
- public void submitOrder(View view) {
- String variable1,variable2,variable3;
- CheckBox cream = (CheckBox) findViewById(R.id.checkbox);
- CheckBox choco = (CheckBox) findViewById(R.id.checkbox_choco);
- boolean value1 = cream.isChecked();
- boolean value2 = choco.isChecked();
- if(value1 == true) {
- variable1 = "Yes";
- topping_price += 1;
- }
- else
- variable1 = "No" ;
- if(value2 == true) {
- variable2 = "Yes";
- topping_price += 2;
- }
- else
- variable2 = "No" ;
- EditText input_name = (EditText) findViewById(R.id.name);
- variable3 = input_name.getText().toString();
- if((quantity + count) == 0){
- topping_price = 0;
- variable1 = "No";
- variable2 = "No";
- }
- String price_message = "Whipped cream topping: " + variable1 + "nChocolate topping: " + variable2 +"nName: " + variable3 +"nQuantity: " + (quantity + count) +"nTotal $" + (( quantity + count ) * 10 + topping_price ) + "nThank You";
- displayMessage(price_message);
- topping_price = 0 ;
- Intent sendIntent = new Intent(Intent.ACTION_SENDTO);
- sendIntent.setType("*/*");
- sendIntent.setData(Uri.parse("masquerade0097@gmail.com"));
- sendIntent.setClassName("com.google.android.gm", "com.google.android.gm.ComposeActivityGmail");
- sendIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { "masquerade0097@gmail.com" });
- sendIntent.putExtra(Intent.EXTRA_SUBJECT, "Just Java order for " + variable3);
- sendIntent.putExtra(Intent.EXTRA_TEXT,"Whipped cream topping: " + variable1 + "nChocolate topping: " + variable2 +"nName: " + variable3 +"nQuantity: " + (quantity + count) +"nTotal $" + (( quantity + count ) * 10 + topping_price ) + "nThank You");
- // startActivity(sendIntent);
- if (sendIntent.resolveActivity(getPackageManager()) != null) {
- startActivity(sendIntent);
- }
- }
- /**
- * This method displays the given text on the screen.
- */
- private void displayMessage(String message) {
- TextView priceTextView = (TextView) findViewById(R.id.price_text_view);
- priceTextView.setText(message);
- }
- int quantity = 1;
- int count = 0;
- public void increment(View view){
- if((quantity + count) < 101)
- count = count + 1;
- display(quantity + count );
- displayPrice( (quantity + count) * 10);
- }
- public void decrement(View view){
- if((quantity + count) != 0)
- count = count - 1;
- display(quantity + count);
- displayPrice((quantity + count) * 10);
- }
- /**
- * This method displays the given quantity value on the screen.
- */
- private void display(int number) {
- TextView quantityTextView = (TextView) findViewById(R.id.quantity_text_view);
- quantityTextView.setText("" + number);
- }
- private void displayPrice(int number){
- TextView priceTextView = (TextView) findViewById(R.id.price_text_view);
- priceTextView.setText(NumberFormat.getCurrencyInstance().format(number));
- }
- }
- Intent intent = new Intent(Intent.ACTION_SEND);
- intent.setType("message/rfc822");
- intent.putExtra(Intent.EXTRA_TEXT, "Text you want to share");
- startActivity(Intent.createChooser(intent, "Send mail..."));
- Intent sendIntent = new Intent(Intent.ACTION_VIEW);
- sendIntent.setData(Uri.parse("test@gmail.com"));
- sendIntent.setClassName("com.google.android.gm","com.google.android.gm.ComposeActivityGmail");
- sendIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { "test@gmail.com" });
- sendIntent.putExtra(Intent.EXTRA_SUBJECT, "Test");
- sendIntent.putExtra(Intent.EXTRA_TEXT, "Test");
- startActivity(sendIntent);
- Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts(
- "mailto", emailId, null));
- emailIntent.putExtra(Intent.EXTRA_SUBJECT, "");
- emailIntent.putExtra(Intent.EXTRA_TEXT, "");
- startActivity(Intent.createChooser(emailIntent, "Send email..."));
- Intent mailClient = new Intent(Intent.ACTION_VIEW);
- mailClient.setClassName("com.google.android.gm", "com.google.android.gm.ConversationListActivity");
- startActivity(mailClient);
- mailClient.putExtra(Intent.EXTRA_EMAIL, new String[] { "hello@gmail.com" });
- mailClient.putExtra(Intent.EXTRA_SUBJECT, "hello subject");
- mailClient.putExtra(Intent.EXTRA_TEXT, "hello message");
Add Comment
Please, Sign In to add comment