Types of intents

implicit intent
-action, data uri, category, components, extras

Implicit Intent

Intent intent = new Intent(Intent.ACTION_SENDTO);
sendIntent.setData(Uri.parse("mailto:"));
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "Just Java order for " + name);
sendIntent.putExtra(Intent.EXTRA_TEXT, priceMessage);

if (sendIntent.resolveActivity(getPackageManager()) != null){
	startActivity(sendIntent);
}

Explicit Intent

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

Use an Intent

Add onclick method on main java file and xml file.

res > layout > activity_main.xml

<?xml version="1.0" encoding="utf-8" ?>
<LinearLayout
	xmlns:android="http://schemas.android.com/apk/res/android"
	xmlns:tools="http://chemas.android.com/tools"
	android:layout_width="match_parent"
	android:layout_height="match_parent"
	android:background="@color/tan_background"
	android:orientation="vertical"
	tools:context="com.example.android.miwok.MainActivity">

	<TextView
		android:id="@+id/numbers"
		style="@style/CategoryStyle"
		android:background="@color/category_numbers"
		android:text="Numbers"
		android:onClick="openNumberList" />

	<TextView
		android:id="@+id/family"
		style="@style/CategoryStyle"
		android:background="@color/category_family"
		android:text="Family Members" />

	<TextView
		android:id="@+id/colors"
		style="@style/CategoryStyle"
		android:background="@color/category_colors"
		android:text="Calors" />

	<TextView
		android:id="@+id/phrases"
		style="@style/CategoryStyle"
		android:background="@color/category_phrases"
		android:text="Phrases" />

</LinearLayout>

MainActivity.java

package com.example.android.miwok;

import android.conent.Intent;
import android.support.v7.app.AppCompactActivity;
import android.os.Bundle;
import android.view.View;

public class MainActivity extends AppCompactActivity {

	@Override
	protected void onCreate(Bundle savedInstanceState){
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
	}

	public void openNumbersList(View view){
		//TODO: Write your code here!
		Intent i = new Intent(this, NumbersActivity.class);
		startActivity(i);
	}
}

android intent tutorial site
http://www.vogella.com/tutorials/AndroidIntent/article.html#usingintents_call

Read MainActivity.java

MainActivity
intent -> NumbersActivity, FamilyActivity, ColorsActivity, PhraseActivity

package com.example.android.miwok;

import android.support.v7.app.AppCompactActivity;
import android.os.Bundle;

public class MainActivity extends AppCompactActivity {

	@Override
	protected void onCreate(Bundle savedInstanceState){
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
	}
}
<application
	android:allowBackup="true"
	android:icon="@mipmap/ic_launcher"
	android:label="Miwok"
	android:supportsRtl="true"
	android:theme="@style/AppTheme" >
	<activity android:name=".MainActivity" >
		<intent-filter>
			<action android:name="android.intent.action.MAIN" />

			<category android:name="android.intent.category.LAUNCHER" />
		</intent-filter>
	</activity>
	<activity android:name=".NumbersActivity" >
	</activity>
	<activity android:name=".FamilyActivity" >
	</activity>
	<activity android:name=".ColorsActivity" >
	</activity>
	<activity android:name=".PhrasesActivity" >
	</activity>
</application>

Navigate to other activities: intent

Miwok language

Miwok app to start off
app / src / main / res / layout / activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2016 The Android Open Source Project
     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at
          http://www.apache.org/licenses/LICENSE-2.0
     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/tan_background"
    android:orientation="vertical"
    tools:context="com.example.android.miwok.MainActivity">

    <TextView
        android:id="@+id/numbers"
        style="@style/CategoryStyle"
        android:background="@color/category_numbers"
        android:text="@string/category_numbers" />

    <TextView
        android:id="@+id/family"
        style="@style/CategoryStyle"
        android:background="@color/category_family"
        android:text="@string/category_family" />

    <TextView
        android:id="@+id/colors"
        style="@style/CategoryStyle"
        android:background="@color/category_colors"
        android:text="@string/category_colors" />

    <TextView
        android:id="@+id/phrases"
        style="@style/CategoryStyle"
        android:background="@color/category_phrases"
        android:text="@string/category_phrases" />

</LinearLayout>
/*
 * Copyright (C) 2016 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.example.android.miwok;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

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

        // Set the content of the activity to use the activity_main.xml layout file
        setContentView(R.layout.activity_main);
    }
}

style

<TextView
	android:layout_width="wrap_content"
	android:layout_height="wrap_content"
	android:layout_marginBottom="16dp"
	android:layout_marginTop="16dp"
	android:text="@string/toppings"
	style="@style/CustomText"
	android:textAllCaps="true" />

Themes of App
https://material.io/guidelines/style/color.html

-color primary
-color primary dark
-color account

email intent android

commont intent
https://developer.android.com/guide/components/intents-common.html

public void addEvent(String title, String location, Calendar begin, Calendar end) {
    Intent intent = new Intent(Intent.ACTION_INSERT)
            .setData(Events.CONTENT_URI)
            .putExtra(Events.TITLE, title)
            .putExtra(Events.EVENT_LOCATION, location)
            .putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, begin)
            .putExtra(CalendarContract.EXTRA_EVENT_END_TIME, end);
    if (intent.resolveActivity(getPackageManager()) != null) {
        startActivity(intent);
    }
}
public void composeEmail(String[] addresses, String subject) {
    Intent intent = new Intent(Intent.ACTION_SENDTO);
    intent.setData(Uri.parse("mailto:")); // only email apps should handle this
    intent.putExtra(Intent.EXTRA_EMAIL, addresses);
    intent.putExtra(Intent.EXTRA_SUBJECT, subject);
    if (intent.resolveActivity(getPackageManager()) != null) {
        startActivity(intent);
    }
}

support localization
https://developer.android.com/guide/topics/resources/localization.html

What’s inside an Intent?

Action, data uri, category, component, extras

Example mas intent
ACTION_VIEW
geo:47.6, -122.3

Example dial intent
ACTION_DIAL
tel:2125551212

Common intent guide
https://developer.android.com/guide/components/intents-common.html?utm_source=udacity&utm_medium=course&utm_campaign=android_basics

static final int REQUEST_IMAGE_CAPTURE = 1;
static final Uri mLocationForPhotos;

public void capturePhoto(String targetFilename) {
    Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    intent.putExtra(MediaStore.EXTRA_OUTPUT,
            Uri.withAppendedPath(mLocationForPhotos, targetFilename));
    if (intent.resolveActivity(getPackageManager()) != null) {
        startActivityForResult(intent, REQUEST_IMAGE_CAPTURE);
    }
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) {
        Bitmap thumbnail = data.getParcelable("data");
        // Do other work with full size photo saved in mLocationForPhotos
        ...
    }
}
 public void submitOrder(View view){

 	Intent intent = new Intent(Intent.ACTION_VIEW);
 	intent.setData(Uri.parse("geo:47.6, 122.3"));
 	if (intent.resolveActivity(getPackageManager()) != null){
 		startActivity(intent);
 	}
 }

check box

	public void decrement(View view){
		quantity = quantity - 1;
		displayQuantity(quantity);
	}

	public void submitOrder(View view){
		CheckBox = whippedCreamCheckBox = (CheckBox) findViewById(R.id.whipped_cream_checkbox);
		boolean hasWhippedCream = whippedCreamCheckBox.isChecked();
		Log.v("MainActivity", "Has whipped cream; " + hasWhippedCream);

		int price = calculatePrice();
		String priceMessage = createOrderSummary(price, hasWhippedCream);
		displayMessage(priceMEssage);
	}

	private int calculatePrice(){ return quantity * 5; }

	private String createOrderSummary(int price, boolean addWhippedCream){
		String priceMessage = "Name: Lyla the Labyrinth";
		priceMessage += "\nQuantity: " + quantity;
		priceMessage += "\nTotal: $" + price;
		priceMessage += "\nThank you!";
		return priceMessage;
	}

java data types

java data types
https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html

boolean: true and false

	public void decrement(View view){
		quantity = quantity - 1;
		displayQuantity(quantity);
	}

	public void submitOrder(View view){
		int price = calculatePrice();
		log.v("MainActivity", "The price is " + price);

		String priceMessage = createOrderSummary(price);
		displayMessage(priceMessage);
	}
	public void decrement(View view){
		quantity = quantity - 1;
		displayQuantity(quantity);
	}

	public void submitOrder(View view){
		CheckBox = whippedCreamCheckBox = (CheckBox) findViewById(R.id.whipped_cream_checkbox);

		int price = calculatePrice();
		String priceMessage = createOrderSummary(price);
		displayMessage(priceMEssage);
	}

checkbox

 public class MyActivity extends Activity {
     protected void onCreate(Bundle icicle) {
         super.onCreate(icicle);

         setContentView(R.layout.content_layout_id);

         final CheckBox checkBox = (CheckBox) findViewById(R.id.checkbox_id);
         if (checkBox.isChecked()) {
             checkBox.setChecked(false);
         }
     }
 }