diff --git a/Android_Beginners/011-012 User Interface/012 User Interface.txt b/Android_Beginners/011-012 User Interface/012 User Interface.txt
new file mode 100644
index 0000000..3323fa5
--- /dev/null
+++ b/Android_Beginners/011-012 User Interface/012 User Interface.txt
@@ -0,0 +1,106 @@
+[source code] Android Development Tutorials - 11 & 12 - User Interface
+
+***** Main Activity.java
+package your.package.name
+
+import android.support.v7.app.AppCompatActivity;
+import android.os.Bundle;
+import android.view.Menu;
+import android.view.MenuItem;
+
+public class MainActivity extends AppCompatActivity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.menu_main, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ // Handle action bar item clicks here. The action bar will
+ // automatically handle clicks on the Home/Up button, so long
+ // as you specify a parent activity in AndroidManifest.xml.
+ int id = item.getItemId();
+
+ //noinspection SimplifiableIfStatement
+ if (id == R.id.action_settings) {
+ return true;
+ }
+
+ return super.onOptionsItemSelected(item);
+ }
+}
+
+
+***** activity_main.xml
+
+
+
+
+
+
+
+
+
+
+
+
+***** strings.xml
+
+
+ NB Videos 11_12
+ MainActivity
+
+ Hello world!
+ Settings
+ Sign In
+ Log In
+
diff --git a/Android_Beginners/013-016 Java Layout/013-016 Java Layout.txt b/Android_Beginners/013-016 Java Layout/013-016 Java Layout.txt
new file mode 100644
index 0000000..6b3e136
--- /dev/null
+++ b/Android_Beginners/013-016 Java Layout/013-016 Java Layout.txt
@@ -0,0 +1,96 @@
+/* API23 WARNING
+ * This activity was created with API21 when ActioinBarActivity was not depreciated.
+ * IF you are using API23 or later then you will need to extend AppCompatActivity
+*/
+****** MainActivity
+
+package your.package.name
+
+import android.support.v7.app.ActionBarActivity;
+import android.os.Bundle;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.widget.RelativeLayout;
+import android.widget.Button;
+import android.graphics.Color;
+import android.widget.EditText;
+import android.content.res.Resources;
+import android.util.TypedValue;
+
+public class MainActivity extends ActionBarActivity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ //Layout
+ RelativeLayout buckysLayout = new RelativeLayout(this);
+ buckysLayout.setBackgroundColor(Color.GREEN);
+
+ //Button
+ Button redButton = new Button(this);
+ redButton.setText("Log In");
+ redButton.setBackgroundColor(Color.RED);
+
+ //Username input
+ EditText username = new EditText(this);
+
+ redButton.setId(1);
+ username.setId(2);
+
+ RelativeLayout.LayoutParams buttonDetails = new RelativeLayout.LayoutParams(
+ RelativeLayout.LayoutParams.WRAP_CONTENT,
+ RelativeLayout.LayoutParams.WRAP_CONTENT
+ );
+ RelativeLayout.LayoutParams usernameDetails = new RelativeLayout.LayoutParams(
+ RelativeLayout.LayoutParams.WRAP_CONTENT,
+ RelativeLayout.LayoutParams.WRAP_CONTENT
+ );
+
+ //Give rules to position widgets
+ usernameDetails.addRule(RelativeLayout.ABOVE, redButton.getId());
+ usernameDetails.addRule(RelativeLayout.CENTER_HORIZONTAL);
+ usernameDetails.setMargins(0,0,0,50);
+
+ buttonDetails.addRule(RelativeLayout.CENTER_HORIZONTAL);
+ buttonDetails.addRule(RelativeLayout.CENTER_VERTICAL);
+
+ Resources r = getResources();
+ int px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,200,
+ r.getDisplayMetrics()
+ );
+
+ username.setWidth(px);
+
+ //Add widget to layout(button is now a child of layout)
+ buckysLayout.addView(redButton, buttonDetails);
+ buckysLayout.addView(username, usernameDetails);
+
+ //Set this activities content/display to this view
+ setContentView(buckysLayout);
+
+ }
+
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.menu_main, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ // Handle action bar item clicks here. The action bar will
+ // automatically handle clicks on the Home/Up button, so long
+ // as you specify a parent activity in AndroidManifest.xml.
+ int id = item.getItemId();
+
+ //noinspection SimplifiableIfStatement
+ if (id == R.id.action_settings) {
+ return true;
+ }
+
+ return super.onOptionsItemSelected(item);
+ }
+}
\ No newline at end of file
diff --git a/Android_Beginners/017 GridLayout/017 GridLayout.txt b/Android_Beginners/017 GridLayout/017 GridLayout.txt
new file mode 100644
index 0000000..ac3fd96
--- /dev/null
+++ b/Android_Beginners/017 GridLayout/017 GridLayout.txt
@@ -0,0 +1,96 @@
+[source code] Android Development Tutorial - 17 GridLayout
+
+***** MainActivity.java
+
+package your.package.name;
+
+import android.support.v7.app.AppCompatActivity;
+import android.os.Bundle;
+import android.view.Menu;
+import android.view.MenuItem;
+
+public class MainActivity extends AppCompatActivity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.menu_main, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ // Handle action bar item clicks here. The action bar will
+ // automatically handle clicks on the Home/Up button, so long
+ // as you specify a parent activity in AndroidManifest.xml.
+ int id = item.getItemId();
+
+ //noinspection SimplifiableIfStatement
+ if (id == R.id.action_settings) {
+ return true;
+ }
+
+ return super.onOptionsItemSelected(item);
+ }
+}
+
+***** activity_main.xml
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Android_Beginners/018-020 Events/018 to 19 Events.txt b/Android_Beginners/018-020 Events/018 to 19 Events.txt
new file mode 100644
index 0000000..8dd082c
--- /dev/null
+++ b/Android_Beginners/018-020 Events/018 to 19 Events.txt
@@ -0,0 +1,59 @@
+/* API23 WARNING
+ * This activity was created with API21 when ActioinBarActivity was not depreciated.
+ * IF you are using API23 or later then you will need to extend AppCompatActivity
+*/
+****** MainActivity
+
+package your.package.name
+
+import android.support.v7.app.ActionBarActivity;
+import android.os.Bundle;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import android.widget.Button;
+import android.widget.TextView;
+
+
+public class MainActivity extends ActionBarActivity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+
+ Button buckysButton = (Button)findViewById(R.id.buckysButton);
+
+ buckysButton.setOnClickListener(
+ new Button.OnClickListener(){
+ public void onClick(View v){
+ TextView buckysText = (TextView)findViewById(R.id.buckysText);
+ buckysText.setText("Good job Hoss!");
+ }
+ }
+ );
+ }
+
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.menu_main, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ // Handle action bar item clicks here. The action bar will
+ // automatically handle clicks on the Home/Up button, so long
+ // as you specify a parent activity in AndroidManifest.xml.
+ int id = item.getItemId();
+
+ //noinspection SimplifiableIfStatement
+ if (id == R.id.action_settings) {
+ return true;
+ }
+
+ return super.onOptionsItemSelected(item);
+ }
+}
\ No newline at end of file
diff --git a/Android_Beginners/018-020 Events/020 Multiple Events.txt b/Android_Beginners/018-020 Events/020 Multiple Events.txt
new file mode 100644
index 0000000..cf287c5
--- /dev/null
+++ b/Android_Beginners/018-020 Events/020 Multiple Events.txt
@@ -0,0 +1,67 @@
+[source code] Android Development Tutorial - 20 - Multiple Events
+
+***** ManiActivity.java
+package com.thenewboston.smartbutton;
+
+import android.support.v7.app.ActionBarActivity;
+import android.os.Bundle;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import android.widget.Button;
+import android.widget.TextView;
+
+
+public class MainActivity extends ActionBarActivity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+
+ Button buckysButton = (Button)findViewById(R.id.buckysButton);
+
+ buckysButton.setOnClickListener(
+ new Button.OnClickListener(){
+ public void onClick(View v){
+ TextView buckysText = (TextView)findViewById(R.id.buckysText);
+ buckysText.setText("Good job Hoss!");
+ }
+ }
+ );
+
+ buckysButton.setOnLongClickListener(
+ new Button.OnLongClickListener(){
+ public boolean onLongClick(View v){
+ TextView buckysText = (TextView)findViewById(R.id.buckysText);
+ buckysText.setText("Holy carp, that was a long one!");
+ return true;
+ }
+ }
+ );
+
+ }
+
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.menu_main, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ // Handle action bar item clicks here. The action bar will
+ // automatically handle clicks on the Home/Up button, so long
+ // as you specify a parent activity in AndroidManifest.xml.
+ int id = item.getItemId();
+
+ //noinspection SimplifiableIfStatement
+ if (id == R.id.action_settings) {
+ return true;
+ }
+
+ return super.onOptionsItemSelected(item);
+ }
+}
diff --git a/Android_Beginners/031-032 MasterDetailFlow/31 to 32 MasterDetailFlow.txt b/Android_Beginners/031-032 MasterDetailFlow/31 to 32 MasterDetailFlow.txt
new file mode 100644
index 0000000..681b35a
--- /dev/null
+++ b/Android_Beginners/031-032 MasterDetailFlow/31 to 32 MasterDetailFlow.txt
@@ -0,0 +1,257 @@
+[source code] Android Development Tutorials - 31 and 32 - Master Detail Flow
+
+Note we did not do anything special for side by side. When I run it on a tablet with a 4dp reduction in size it showed both.
+
+***** Manifest.xml
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+***** WebpageDetailFragment.java
+package your.package.nbv31mdflow;
+
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.webkit.WebView;
+
+import your.package.nbv31mdflow.dummy.DummyContent;
+
+/**
+ * A fragment representing a single Webpage detail screen.
+ * This fragment is either contained in a {@link WebpageListActivity}
+ * in two-pane mode (on tablets) or a {@link WebpageDetailActivity}
+ * on handsets.
+ */
+public class WebpageDetailFragment extends Fragment {
+ /**
+ * The fragment argument representing the item ID that this fragment
+ * represents.
+ */
+ public static final String ARG_ITEM_ID = "item_id";
+
+ /**
+ * The dummy content this fragment is presenting.
+ */
+ private DummyContent.DummyItem mItem;
+
+ /**
+ * Mandatory empty constructor for the fragment manager to instantiate the
+ * fragment (e.g. upon screen orientation changes).
+ */
+ public WebpageDetailFragment() {
+ }
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ if (getArguments().containsKey(ARG_ITEM_ID)) {
+ // Load the dummy content specified by the fragment
+ // arguments. In a real-world scenario, use a Loader
+ // to load content from a content provider.
+ mItem = DummyContent.ITEM_MAP.get(getArguments().getString(ARG_ITEM_ID));
+ }
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ View rootView = inflater.inflate(R.layout.fragment_webpage_detail, container, false);
+
+ // Show the dummy content as text in a TextView.
+ if (mItem != null) {
+ ((WebView) rootView.findViewById(R.id.detail_area)).loadUrl(mItem.url);
+ }
+
+ return rootView;
+ }
+}
+
+***** DummyContent.java
+
+package your.package.nbv31mdflow.dummy;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Helper class for providing sample content for user interfaces created by
+ * Android template wizards.
+ *
+ * TODO: Replace all uses of this class before publishing your app.
+ */
+public class DummyContent {
+
+ /**
+ * An array of sample (dummy) items.
+ */
+ public static List ITEMS = new ArrayList();
+
+ /**
+ * A map of sample (dummy) items, by ID.
+ */
+ public static Map ITEM_MAP = new HashMap();
+
+ static {
+ // Add 3 sample items.
+ addItem(new DummyItem("1", "Android Tutorails", "https://www.thenewboston.com/videos.php?cat=278"));
+ addItem(new DummyItem("2", "SQLite Tutorial", "http://www.vogella.com/tutorials/AndroidSQLite/article.html"));
+ addItem(new DummyItem("3", "Developer Tutorials", "http://developer.android.com/training/index.html"));
+ }
+
+ private static void addItem(DummyItem item) {
+ ITEMS.add(item);
+ ITEM_MAP.put(item.id, item);
+ }
+
+ /**
+ * A dummy item representing a piece of content.
+ */
+ public static class DummyItem {
+ public String id;
+ public String item_name;
+ public String url;
+
+ public DummyItem(String id, String item_name, String url) {
+ this.id = id;
+ this.item_name = item_name;
+ this.url = url;
+ }
+
+ @Override
+ public String toString() {
+ return item_name;
+ }
+ }
+}
+
+***** fragment_webpage_detail.xml
+
+
+
+***** WebpageListActivity
+package your.package.nbv31mdflow;
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.support.v4.app.FragmentActivity;
+
+
+/**
+ * An activity representing a list of Webpages. This activity
+ * has different presentations for handset and tablet-size devices. On
+ * handsets, the activity presents a list of items, which when touched,
+ * lead to a {@link WebpageDetailActivity} representing
+ * item details. On tablets, the activity presents the list of items and
+ * item details side-by-side using two vertical panes.
+ *
+ * The activity makes heavy use of fragments. The list of items is a
+ * {@link WebpageListFragment} and the item details
+ * (if present) is a {@link WebpageDetailFragment}.
+ *
+ * This activity also implements the required
+ * {@link WebpageListFragment.Callbacks} interface
+ * to listen for item selections.
+ */
+public class WebpageListActivity extends FragmentActivity
+ implements WebpageListFragment.Callbacks {
+
+ /**
+ * Whether or not the activity is in two-pane mode, i.e. running on a tablet
+ * device.
+ */
+ private boolean mTwoPane;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_webpage_list);
+
+ if (findViewById(R.id.webpage_detail_container) != null) {
+ // The detail container view will be present only in the
+ // large-screen layouts (res/values-large and
+ // res/values-sw600dp). If this view is present, then the
+ // activity should be in two-pane mode.
+ mTwoPane = true;
+
+ // In two-pane mode, list items should be given the
+ // 'activated' state when touched.
+ ((WebpageListFragment) getSupportFragmentManager()
+ .findFragmentById(R.id.webpage_list))
+ .setActivateOnItemClick(true);
+ }
+
+ // TODO: If exposing deep links into your app, handle intents here.
+ }
+
+ /**
+ * Callback method from {@link WebpageListFragment.Callbacks}
+ * indicating that the item with the given ID was selected.
+ */
+ @Override
+ public void onItemSelected(String id) {
+ if (mTwoPane) {
+ // In two-pane mode, show the detail view in this activity by
+ // adding or replacing the detail fragment using a
+ // fragment transaction.
+ Bundle arguments = new Bundle();
+ arguments.putString(WebpageDetailFragment.ARG_ITEM_ID, id);
+ WebpageDetailFragment fragment = new WebpageDetailFragment();
+ fragment.setArguments(arguments);
+ getSupportFragmentManager().beginTransaction()
+ .replace(R.id.webpage_detail_container, fragment)
+ .commit();
+
+ } else {
+ // In single-pane mode, simply start the detail activity
+ // for the selected item ID.
+ Intent detailIntent = new Intent(this, WebpageDetailActivity.class);
+ detailIntent.putExtra(WebpageDetailFragment.ARG_ITEM_ID, id);
+ startActivity(detailIntent);
+ }
+ }
+}
+
+
+***** activity_webpage_list.xml
+
diff --git a/Android_Beginners/033 Overflow Menu/033 Overflow menu.txt b/Android_Beginners/033 Overflow Menu/033 Overflow menu.txt
new file mode 100644
index 0000000..80ce408
--- /dev/null
+++ b/Android_Beginners/033 Overflow Menu/033 Overflow menu.txt
@@ -0,0 +1,130 @@
+[source code] Android Development Tutorial - 33 - Overflow Menu
+
+***** MainActivity
+package your.package.name.nbv33overflowmenu;
+
+import android.graphics.Color;
+import android.support.v7.app.AppCompatActivity;
+import android.os.Bundle;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.widget.RelativeLayout;
+
+public class MainActivity extends AppCompatActivity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.menu_main, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ RelativeLayout main_view = (RelativeLayout)findViewById(R.id.main_view);
+ switch (item.getItemId()){
+ case R.id.menu_red:{
+ if (item.isChecked())
+ item.setChecked(false);
+ else
+ item.setChecked(true);
+ main_view.setBackgroundColor(Color.RED);
+ return true;
+ }
+
+ case R.id.menu_green:{
+ if (item.isChecked())
+ item.setChecked(false);
+ else
+ item.setChecked(true);
+ main_view.setBackgroundColor(Color.GREEN);
+ return true;
+ }
+
+ case R.id.menu_yellow:{
+ if (item.isChecked())
+ item.setChecked(false);
+ else
+ item.setChecked(true);
+ main_view.setBackgroundColor(Color.YELLOW);
+ return true;
+ }
+
+ default:
+ return super.onOptionsItemSelected(item);
+ }
+ }
+}
+
+
+***** activity_main.xml
+
+
+
+
+
+
+***** menu_main.xml
+
+
+
+***** strings.xml
+
+
+ NBV33OverFlowMenu
+
+ Red
+ Green
+ Yellow
+ Select a color from the overflow menu, to change the screen background color.
+
+ Settings
+
+
diff --git a/Android_Beginners/034 Transition/34 Transition.txt b/Android_Beginners/034 Transition/34 Transition.txt
new file mode 100644
index 0000000..ba86248
--- /dev/null
+++ b/Android_Beginners/034 Transition/34 Transition.txt
@@ -0,0 +1,94 @@
+[source code] Android Development Tutorial - 34 - Transitions
+
+***** MainActivity
+package your.package.name.transition;
+
+import android.support.v7.app.AppCompatActivity;
+import android.os.Bundle;
+import android.transition.TransitionManager;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.RelativeLayout;
+
+
+public class MainActivity extends AppCompatActivity {
+ ViewGroup rlParent;
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+
+ rlParent = (ViewGroup)findViewById(R.id.rlParent);
+ rlParent.setOnTouchListener(
+ new RelativeLayout.OnTouchListener() {
+ @Override
+ public boolean onTouch(View v, MotionEvent event) {
+ moveButton();
+ return true;
+ }
+ }
+ );
+ }
+
+ public void moveButton(){
+ View btnObject = findViewById(R.id.btnObject);
+ TransitionManager.beginDelayedTransition(rlParent);
+
+ // Change the position of the button
+ RelativeLayout.LayoutParams positionRules = new RelativeLayout.LayoutParams(
+ RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
+ positionRules.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
+ positionRules.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE);
+ btnObject.setLayoutParams(positionRules);
+
+ //Change the size of the button
+ ViewGroup.LayoutParams sizeRules = btnObject.getLayoutParams();
+ sizeRules.width = 450;
+ sizeRules.height= 300;
+ btnObject.setLayoutParams(sizeRules);
+ }
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.menu_main, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ // Handle action bar item clicks here. The action bar will
+ // automatically handle clicks on the Home/Up button, so long
+ // as you specify a parent activity in AndroidManifest.xml.
+ int id = item.getItemId();
+
+ //noinspection SimplifiableIfStatement
+ if (id == R.id.action_settings) {
+ return true;
+ }
+
+ return super.onOptionsItemSelected(item);
+ }
+}
+
+
+***** activity_main
+
+
+
+
+
diff --git a/Android_Beginners/035-036 Intents/35 to 36 Intents.txt b/Android_Beginners/035-036 Intents/35 to 36 Intents.txt
new file mode 100644
index 0000000..29d72a1
--- /dev/null
+++ b/Android_Beginners/035-036 Intents/35 to 36 Intents.txt
@@ -0,0 +1,198 @@
+[source code] Android Development Tutorial - 35 and 36 - Intents
+
+***** Apples.java (MainActivity)
+
+package your.package.intentexample;
+
+import android.content.Intent;
+import android.support.v7.app.AppCompatActivity;
+import android.os.Bundle;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import android.widget.EditText;
+
+public class Apples extends AppCompatActivity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_apples);
+ }
+
+ public void baconClick(View view){
+ Intent I = new Intent(this, Bacon.class);
+ // get user input
+ final EditText userInput = (EditText) findViewById(R.id.ptvUserInput);
+ String userMessage = userInput.getText().toString();
+ // pass user input in the intent
+ I.putExtra("applesMessage", userMessage);
+
+ startActivity(I);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.menu_main, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ // Handle action bar item clicks here. The action bar will
+ // automatically handle clicks on the Home/Up button, so long
+ // as you specify a parent activity in AndroidManifest.xml.
+ int id = item.getItemId();
+
+ //noinspection SimplifiableIfStatement
+ if (id == R.id.action_settings) {
+ return true;
+ }
+
+ return super.onOptionsItemSelected(item);
+ }
+}
+
+
+***** activity_apples.xml
+
+
+
+
+
+
+
+
+
+
+
+***** Strings.xml
+
+
+ Intent Example
+
+ Settings
+ Apples
+ Go To Bacon
+ Bacon
+ Bacon
+ Go To Apples
+
+
+***** Bacon.java (Second Activity)
+package your.package.intentexample;
+
+import android.content.Intent;
+import android.support.v7.app.AppCompatActivity;
+import android.os.Bundle;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import android.widget.TextView;
+
+public class Bacon extends AppCompatActivity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_bacon);
+
+ Bundle appleData = getIntent().getExtras();
+ if (appleData== null){
+ return;
+ }
+ String applesMessage = appleData.getString("applesMessage");
+ TextView tvBacon = (TextView) findViewById(R.id.tvBacon);
+ tvBacon.setText(applesMessage);
+ }
+ public void applesClick(View view){
+ Intent I = new Intent(this, Apples.class);
+ startActivity(I);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.menu_bacon, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ // Handle action bar item clicks here. The action bar will
+ // automatically handle clicks on the Home/Up button, so long
+ // as you specify a parent activity in AndroidManifest.xml.
+ int id = item.getItemId();
+
+ //noinspection SimplifiableIfStatement
+ if (id == R.id.action_settings) {
+ return true;
+ }
+
+ return super.onOptionsItemSelected(item);
+ }
+}
+
+
+***** activity_Bacon.xml
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Android_Beginners/039-040 Threads/39 to 40 Threads.txt b/Android_Beginners/039-040 Threads/39 to 40 Threads.txt
new file mode 100644
index 0000000..f3400bc
--- /dev/null
+++ b/Android_Beginners/039-040 Threads/39 to 40 Threads.txt
@@ -0,0 +1,127 @@
+[source code] Android Development Tutorial - 39 & 40 Threads
+
+***** MainActivity.java
+package your.package.nbv39threads;
+
+import android.os.Handler;
+import android.os.Message;
+import android.support.v7.app.AppCompatActivity;
+import android.os.Bundle;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import android.widget.TextView;
+import android.widget.Toast;
+
+
+
+public class MainActivity extends AppCompatActivity {
+ Handler waitMsgHandler = new Handler(){
+ @Override
+ public void handleMessage(Message msg) {
+ TextView tv1 = (TextView) findViewById(R.id.tv1);
+ tv1.setText("Nice Job hoss!");
+ }
+ };
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+ }
+
+ public void btn1Clicked(View view){
+// Lesson 40
+ Runnable r = new Runnable() {
+ @Override
+ public void run() {
+ // What do you want the thread to do
+ long futureTime = (System.currentTimeMillis()+ 10000);//10 sec
+
+ while (System.currentTimeMillis()< futureTime){
+ // Don't need to sync when you are not using a thread e,g, Tutorial 39
+ synchronized(this){
+ try {
+ wait(futureTime - System.currentTimeMillis());
+ }catch(Exception e){}
+ }
+ }
+ waitMsgHandler.sendEmptyMessage(0);
+
+ }
+ };
+
+ Thread waitThread = new Thread(r);
+ waitThread.start();
+ //This toast will execute immediately
+ Toast.makeText(MainActivity.this,"Running thread fo 10 seconds",Toast.LENGTH_LONG).show();
+
+/*
+ long futureTime = (System.currentTimeMillis()+ 10000);//10 sec
+ // The Toast may not show if the futureTime is more than 3 seconds.
+ // Even though it is programed first.
+ Toast.makeText(MainActivity.this,"Waiting 2 seconds",Toast.LENGTH_LONG).show();
+
+ while (System.currentTimeMillis()< futureTime){
+ // Don't need to sync when you are not using a thread e,g, Tutorial 39
+ synchronized(this){
+ try {
+ wait(futureTime - System.currentTimeMillis());
+ }catch(Exception e){}
+ }
+ }
+
+ // If you leave this here it will update as soon as the button is clicked. Move it to a handler.
+ TextView tv1 = (TextView) findViewById(R.id.tv1);
+ tv1.setText("Nice Job hoss!");
+*/ }
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.menu_main, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ // Handle action bar item clicks here. The action bar will
+ // automatically handle clicks on the Home/Up button, so long
+ // as you specify a parent activity in AndroidManifest.xml.
+ int id = item.getItemId();
+
+ //noinspection SimplifiableIfStatement
+ if (id == R.id.action_settings) {
+ return true;
+ }
+
+ return super.onOptionsItemSelected(item);
+ }
+}
+
+***** activity_main.xml
+
+
+
+
+
+
+
diff --git a/Android_Beginners/041-042 Intent Service/41 to 42 Intent Service.txt b/Android_Beginners/041-042 Intent Service/41 to 42 Intent Service.txt
new file mode 100644
index 0000000..83a10f8
--- /dev/null
+++ b/Android_Beginners/041-042 Intent Service/41 to 42 Intent Service.txt
@@ -0,0 +1,220 @@
+[source code] Android Development Tutorial - 41 to 42 - Intent Service
+
+**** MainActivity.java
+package your.package.nbv41services;
+// I didn't reuse the Apples Bacon app like Bucky
+import android.content.Intent;
+import android.support.v7.app.AppCompatActivity;
+import android.os.Bundle;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.widget.CompoundButton;
+import android.widget.TextView;
+import android.widget.ToggleButton;
+
+public class MainActivity extends AppCompatActivity {
+ TextView tvToggleState;
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+ ToggleButton toggle = (ToggleButton) findViewById(R.id.toggleButton);
+ tvToggleState = (TextView) findViewById(R.id.tvToggleState);
+
+ toggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+ if (isChecked) {
+ // The toggle is enabled
+ tvToggleState.setText("ON");
+ } else {
+ // The toggle is disabled
+ tvToggleState.setText("OFF");
+ }
+ }
+ });
+ // Lesson 41
+ Intent intent = new Intent(this,TheIntentService.class);
+ startService(intent);
+ // Lesson 42
+ Intent lesson42Service = new Intent(this,Lesson42Service.class);
+ startService(lesson42Service);
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.menu_main, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ // Handle action bar item clicks here. The action bar will
+ // automatically handle clicks on the Home/Up button, so long
+ // as you specify a parent activity in AndroidManifest.xml.
+ int id = item.getItemId();
+
+ //noinspection SimplifiableIfStatement
+ if (id == R.id.action_settings) {
+ return true;
+ }
+
+ return super.onOptionsItemSelected(item);
+ }
+}
+
+***** TheIntentService.java
+package info.glwhiitney.nbv41services;
+// Tutorial 41
+import android.annotation.SuppressLint;
+import android.app.IntentService;
+import android.content.Intent;
+import android.util.Log;
+
+public class TheIntentService extends IntentService {
+ public static final String TAG = "info.glwhiitney.nbv41services";
+
+ public TheIntentService() { // I think you normally pass in the name of the intent service, but he deleted it.
+ super("TheIntentService");
+ }
+
+ @SuppressLint("LongLogTag")
+ @Override
+ protected void onHandleIntent(Intent intent) {
+ // this is what the service does.
+ Log.i(TAG,"#41 Intent now started.");
+ }
+
+
+}
+
+***** Lesson42Service.java
+package info.glwhiitney.nbv41services;
+
+import android.annotation.SuppressLint;
+import android.app.Service;
+import android.content.Intent;
+import android.os.IBinder;
+import android.util.Log;
+
+public class Lesson42Service extends Service {
+ public static final String TAG = "info.glwhiitney.nbv41services";
+
+ public Lesson42Service() {
+ }
+
+ @Override
+ public int onStartCommand(Intent intent, int flags, int startId) {
+ // default - return super.onStartCommand(intent, flags, startId);
+ Log.i(TAG,"L42 onStartCommand called");
+ Runnable r = new Runnable() {
+ @Override
+ public void run() {
+ // What do you want the thread to do
+ for (int i = 0; i < 5; i++) {
+ long futureTime = (System.currentTimeMillis() + 5000);// 5 sec
+
+ while (System.currentTimeMillis() < futureTime) {
+ // Don't need to sync when you are not using a thread e,g, Tutorial 39
+ synchronized (this) {
+ try {
+ wait(futureTime - System.currentTimeMillis());
+ Log.i(TAG, "L42 loop "+ i + " finished");
+ } catch (Exception e) {
+
+ }
+ }
+ }
+ }
+ }
+ };
+ // start the thread
+ Thread less42Thread = new Thread(r);
+ less42Thread.start();
+ return Service.START_STICKY; // restarts the service if it gets destroyed.
+ }
+
+ @SuppressLint("LongLogTag")
+ @Override
+ public void onDestroy() {
+ //Removed default super
+ Log.i(TAG,"L42 onDestroy called");
+ }
+
+ @Override
+ public IBinder onBind(Intent intent) {
+ // This is not a bound service
+ // throw new UnsupportedOperationException("Not yet implemented");
+ return null;
+ }
+}
+
+***** Android Manifest
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+*****activity_main.xml
+
+
+
+
+
+
+
+
+***** Strings.xml
+
+ NBV41Services
+ Settings
+ ON
+ OFF
+ Toggle Me While Services Run
+
diff --git a/Android_Beginners/043-044 Bound Services/43 to 44 Bound Services.txt b/Android_Beginners/043-044 Bound Services/43 to 44 Bound Services.txt
new file mode 100644
index 0000000..366f906
--- /dev/null
+++ b/Android_Beginners/043-044 Bound Services/43 to 44 Bound Services.txt
@@ -0,0 +1,141 @@
+[source code] Android Development Tutorial - 43 and 44 - Bound Services
+
+***** MainActivity.java
+package your.package.nbv43boundservice;
+
+import android.support.v7.app.AppCompatActivity;
+import android.os.Bundle;
+import android.view.Menu;
+import android.view.MenuItem;
+//Lesson43 imports
+import android.view.View;
+import android.widget.TextView;
+import android.os.IBinder;
+import android.content.Context;
+import android.content.Intent;
+import android.content.ComponentName;
+import android.content.ServiceConnection;
+import your.package.nbv43boundservice.Lesson43TimeService.MyLocalBinder;
+
+
+public class MainActivity extends AppCompatActivity {
+ Lesson43TimeService theService;
+ boolean isBound = false;
+ //Lesson 44
+ public void btnShowTime(View view){
+ String currentTime = theService.getCurrentTime();
+ TextView tvShowTime = (TextView) findViewById(R.id.tvShowTime);
+ tvShowTime.setText(currentTime);
+ }
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+ Intent i = new Intent(this, Lesson43TimeService.class);
+ bindService(i, theConnection, Context.BIND_AUTO_CREATE);
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // AS comment - Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.menu_main, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ // AS comment - Handle action bar item clicks here. The action bar will
+ // AS comment - automatically handle clicks on the Home/Up button, so long
+ // AS comment - as you specify a parent activity in AndroidManifest.xml.
+ int id = item.getItemId();
+
+ // AS comment - noinspection SimplifiableIfStatement
+ if (id == R.id.action_settings) {
+ return true;
+ }
+
+ return super.onOptionsItemSelected(item);
+ }
+ private ServiceConnection theConnection = new ServiceConnection() {
+ @Override
+ public void onServiceConnected(ComponentName name, IBinder service) {
+ // get a ref to the binder class and call the bind method
+ MyLocalBinder binder = (MyLocalBinder) service;
+ theService = binder.getService();
+ isBound = true;
+ }
+
+ @Override
+ public void onServiceDisconnected(ComponentName name) {
+ isBound = false;
+ }
+ };
+
+
+}
+
+
+***** activity_main.xml
+
+
+
+
+
+
+
+***** Lesson43TimeService.java
+
+package your.package.nbv43boundservice;
+
+import android.app.Service;
+import android.content.Intent;
+import android.os.IBinder;
+import android.os.Binder;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Locale;
+
+public class Lesson43TimeService extends Service {
+ private final IBinder lesson43Binder = new MyLocalBinder();
+ public Lesson43TimeService() {
+ }
+
+ @Override
+ public IBinder onBind(Intent intent) {
+ // Buckky deleted
+ // throw new UnsupportedOperationException("Not yet implemented");
+ return lesson43Binder;
+ }
+ public String getCurrentTime(){
+ SimpleDateFormat df = new SimpleDateFormat("HH:mm:ss", Locale.US);
+ return (df.format(new Date()));
+ }
+
+ public class MyLocalBinder extends Binder {
+ Lesson43TimeService getService(){
+ return Lesson43TimeService.this;
+ }
+ }
+
+}
diff --git a/Android_Beginners/045-048 List Items/45 to 46 Simple List Items.txt b/Android_Beginners/045-048 List Items/45 to 46 Simple List Items.txt
new file mode 100644
index 0000000..2719c0c
--- /dev/null
+++ b/Android_Beginners/045-048 List Items/45 to 46 Simple List Items.txt
@@ -0,0 +1,55 @@
+[source code] Android Development Tutorial - 45 & 46 Simple list items
+
+***** MainActivity.java
+
+package your.package.listexample
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
+import android.widget.ListAdapter;
+import android.widget.ListView;
+import android.widget.Toast;
+
+public class MainActivity extends Activity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+
+ String[] foods = {"Bacon", "Ham", "Tuna", "Candy", "Meatball", "Potato"};
+ ListAdapter buckysAdapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, foods);
+ ListView buckysListView = (ListView) findViewById(R.id.buckysListView);
+ buckysListView.setAdapter(buckysAdapter);
+
+ buckysListView.setOnItemClickListener(
+ new AdapterView.OnItemClickListener(){
+ @Override
+ public void onItemClick(AdapterView> parent, View view, int position, long id) {
+ String food = String.valueOf(parent.getItemAtPosition(position));
+ Toast.makeText(MainActivity.this, food, Toast.LENGTH_LONG).show();
+ }
+ }
+ );
+ }
+
+}
+
+***** activity_main.xml
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Android_Beginners/045-048 List Items/47 to 48 Custom List Items.txt b/Android_Beginners/045-048 List Items/47 to 48 Custom List Items.txt
new file mode 100644
index 0000000..13767ee
--- /dev/null
+++ b/Android_Beginners/045-048 List Items/47 to 48 Custom List Items.txt
@@ -0,0 +1,120 @@
+[source code] Android Development Tutorial - 47 & 48 Custom List Items
+
+**** MainActivity.java
+
+package your.package.nbv47customlistitem;
+/*
+The only difference here is we are going to use a our Custom adapter instead of an Array Adapter.
+We pass the foods array as part of the constructor.
+Note: we don't have an array of images so we use the same one every time,
+else we would modify CustomAdapter to accept that array too.
+ */
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.AdapterView;
+import android.widget.ListAdapter;
+import android.widget.ListView;
+import android.widget.Toast;
+
+public class MainActivity extends Activity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+ String[] foods = {"Bacon", "Ham", "Tuna", "Candy", "Meatball", "Potato"};
+ // Replace the Array adapter with your custom adapter.
+ // ListAdapter theListAdapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, foods);
+ ListAdapter customListAdapter = new CustomAdapter(this,foods);// Pass the food arrary to the constructor.
+ ListView customListView = (ListView) findViewById(R.id.custom_ListView);
+ customListView.setAdapter(customListAdapter);
+
+ customListView.setOnItemClickListener(
+ new AdapterView.OnItemClickListener() {
+ @Override
+ public void onItemClick(AdapterView> parent, View view, int position, long id) {
+ String food = String.valueOf(parent.getItemAtPosition(position));
+ Toast.makeText(MainActivity.this, food, Toast.LENGTH_LONG).show();
+ }
+ }
+ );
+ }
+}
+
+***** CustomAdapter.java
+
+package your.package.nbv47customlistitem;
+// Lesson 48
+import android.content.Context;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+class CustomAdapter extends ArrayAdapter{
+ public CustomAdapter(Context context, String[] foods) {
+ super(context, R.layout.custom_row ,foods);
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ // default - return super.getView(position, convertView, parent);
+ // add the layout
+ LayoutInflater myCustomInflater = LayoutInflater.from(getContext());
+ View customView = myCustomInflater.inflate(R.layout.custom_row, parent, false);
+ // get references.
+ String singleFoodItem = getItem(position);
+ TextView itemText = (TextView) customView.findViewById(R.id.item_text);
+ ImageView buckysImage = (ImageView) customView.findViewById(R.id.my_profile_image);
+
+ // dynamically update the text from the array
+ itemText.setText(singleFoodItem);
+ // using the same image every time
+ buckysImage.setImageResource(R.drawable.myprofile);
+ // Now we can finally return our custom View or custom item
+ return customView;
+ }
+}
+
+***** activity_main.xml
+
+
+
+
+
+
+***** custom_row.xml
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Android_Beginners/049-054 SQLite/49 to 54 SQLite.txt b/Android_Beginners/049-054 SQLite/49 to 54 SQLite.txt
new file mode 100644
index 0000000..59ced5e
--- /dev/null
+++ b/Android_Beginners/049-054 SQLite/49 to 54 SQLite.txt
@@ -0,0 +1,219 @@
+New Boston Tutorials 49 to 54 SQLite
+
+***** Main Activity.java
+
+package your.package.nbv40sqlitesample;
+// Lesson 54
+import android.app.Activity;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.EditText;
+import android.widget.TextView;
+
+public class MainActivity extends Activity {
+// Declare references
+
+ EditText userInput;
+ TextView recordsTextView;
+ MyDBHandler dbHandler;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+
+ userInput = (EditText) findViewById(R.id.user_Input);
+ recordsTextView = (TextView) findViewById(R.id.records_TextView);
+ /* Can pass nulls because of the constants in the helper.
+ * the 1 means version 1 so don't run update.
+ */
+ dbHandler = new MyDBHandler(this, null, null, 1);
+ printDatabase();
+ }
+
+ //Print the database
+ public void printDatabase(){
+ String dbString = dbHandler.databaseToString();
+ recordsTextView.setText(dbString);
+ userInput.setText("");
+ }
+
+ //add your elements onclick methods.
+ //Add a product to the database
+ public void addButtonClicked(View view){
+ // dbHandler.add needs an object parameter.
+ Products product = new Products(userInput.getText().toString());
+ dbHandler.addProduct(product);
+ printDatabase();
+ }
+
+ //Delete items
+ public void deleteButtonClicked(View view){
+ // dbHandler delete needs string to find in the db
+ String inputText = userInput.getText().toString();
+ dbHandler.deleteProduct(inputText);
+ printDatabase();
+ }
+
+}
+
+
+***** activity_main.xml
+
+
+
+
+
+
+
+
+
+
+
+
+
+***** Products.java
+
+package your.package.nbv40sqlitesample;
+// Lesson 50
+
+public class Products {
+ private int _id;
+ private String _productname;
+
+ //Added this empty constructor in lesson 50 in case we ever want to create the object and assign it later.
+ public Products(){
+
+ }
+ public Products(String productName) {
+ this._productname = productName;
+ }
+
+ public int get_id() {
+ return _id;
+ }
+
+ public void set_id(int _id) {
+ this._id = _id;
+ }
+
+ public String get_productname() {
+ return _productname;
+ }
+
+ public void set_productname(String _productname) {
+ this._productname = _productname;
+ }
+}
+
+***** MyDBHandler.java
+package your.package.nbv40sqlitesample;
+
+// This class handles all the database activities
+import android.database.sqlite.SQLiteDatabase;
+import android.database.sqlite.SQLiteOpenHelper;
+import android.database.Cursor;
+import android.content.Context;
+import android.content.ContentValues;
+
+public class MyDBHandler extends SQLiteOpenHelper{
+ private static final int DATABASE_VERSION = 1;
+ private static final String DATABASE_NAME = "productDB.db";
+ public static final String TABLE_PRODUCTS = "products";
+ public static final String COLUMN_ID = "_id";
+ public static final String COLUMN_PRODUCTNAME = "productname";
+
+ //We need to pass database information along to superclass
+ public MyDBHandler(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
+ super(context, DATABASE_NAME, factory, DATABASE_VERSION);
+ }
+
+ @Override
+ public void onCreate(SQLiteDatabase db) {
+ String query = "CREATE TABLE " + TABLE_PRODUCTS + "(" +
+ COLUMN_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
+ COLUMN_PRODUCTNAME + " TEXT " +
+ ");";
+ db.execSQL(query);
+ }
+ //Lesson 51
+ @Override
+ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
+ db.execSQL("DROP TABLE IF EXISTS " + TABLE_PRODUCTS);
+ onCreate(db);
+ }
+
+ //Add a new row to the database
+ public void addProduct(Products product){
+ ContentValues values = new ContentValues();
+ values.put(COLUMN_PRODUCTNAME, product.get_productname());
+ SQLiteDatabase db = getWritableDatabase();
+ db.insert(TABLE_PRODUCTS, null, values);
+ db.close();
+ }
+
+ //Delete a product from the database
+ public void deleteProduct(String productName){
+ SQLiteDatabase db = getWritableDatabase();
+ db.execSQL("DELETE FROM " + TABLE_PRODUCTS + " WHERE " + COLUMN_PRODUCTNAME + "=\"" + productName + "\";");
+ }
+
+ // this is goint in record_TextView in the Main activity.
+ public String databaseToString(){
+ String dbString = "";
+ SQLiteDatabase db = getWritableDatabase();
+ String query = "SELECT * FROM " + TABLE_PRODUCTS + " WHERE 1";// why not leave out the WHERE clause?
+
+ //Cursor points to a location in your results
+ Cursor recordSet = db.rawQuery(query, null);
+ //Move to the first row in your results
+ recordSet.moveToFirst();
+
+ //Position after the last row means the end of the results
+ while (!recordSet.isAfterLast()) {
+ // null could happen if we used our empty constructor
+ if (recordSet.getString(recordSet.getColumnIndex("productname")) != null) {
+ dbString += recordSet.getString(recordSet.getColumnIndex("productname"));
+ dbString += "\n";
+ }
+ recordSet.moveToNext();
+ }
+ db.close();
+ return dbString;
+ }
+
+}
diff --git a/Android_Beginners/055 Play Video/55 Play Video.txt b/Android_Beginners/055 Play Video/55 Play Video.txt
new file mode 100644
index 0000000..d51da04
--- /dev/null
+++ b/Android_Beginners/055 Play Video/55 Play Video.txt
@@ -0,0 +1,50 @@
+[source code] Android Development Tutorial - 55 Play Video
+/* API23 WARNING
+ * This activity was created with API21 when ActioinBarActivity was not depreciated.
+ * IF you are using API23 or later then you will need to extend AppCompatActivity
+*/
+
+
+package your.package.name
+***** activity_main.xml
+
+
+
+
+
+
+***** MainActivity.java
+
+package com.thenewboston.videoplayer;
+
+import android.support.v7.app.ActionBarActivity;
+import android.os.Bundle;
+import android.widget.VideoView;
+import android.widget.MediaController;
+
+public class MainActivity extends ActionBarActivity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+
+ final VideoView buckysVideoView = (VideoView) findViewById(R.id.buckysVideoView);
+ buckysVideoView.setVideoPath("https://www.thenewboston.com/forum/project_files/006_testVideo.mp4");
+
+ //Player controls(play, pause, stop, etc...)
+ MediaController mediaController = new MediaController(this);
+ mediaController.setAnchorView(buckysVideoView);
+ buckysVideoView.setMediaController(mediaController);
+
+ buckysVideoView.start();
+ }
+
+}
\ No newline at end of file
diff --git a/Android_Beginners/056-057 Camera Intent/56 to 57 Camera Intent.txt b/Android_Beginners/056-057 Camera Intent/56 to 57 Camera Intent.txt
new file mode 100644
index 0000000..f1276fd
--- /dev/null
+++ b/Android_Beginners/056-057 Camera Intent/56 to 57 Camera Intent.txt
@@ -0,0 +1,94 @@
+/* API23 WARNING
+ * This activity was created with API21 when ActioinBarActivity was not depreciated.
+ * IF you are using API23 or later then you will need to extend AppCompatActivity
+*/
+
+
+package your.package.name[source code] Android Development Tutorial - 56 & 57 Camera Intent
+
+***** activity_main.xml
+
+
+
+
+
+
+
+***** MainActivity.java
+
+package com.thenewboston.takephoto;
+
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.graphics.Bitmap;
+import android.provider.MediaStore;
+import android.support.v7.app.ActionBarActivity;
+import android.os.Bundle;
+import android.content.pm.PackageInfo;
+import android.view.View;
+import android.widget.Button;
+import android.widget.ImageView;
+
+public class MainActivity extends ActionBarActivity {
+
+ static final int REQUEST_IMAGE_CAPTURE = 1;
+ ImageView buckysImageView;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+
+ Button buckyButton = (Button) findViewById(R.id.buckysButton);
+ buckysImageView = (ImageView) findViewById(R.id.buckysImageView);
+
+ //Disable the button if the user has no camera
+ if(!hasCamera())
+ buckyButton.setEnabled(false);
+ }
+
+ //Check if the user has a camera
+ private boolean hasCamera(){
+ return getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_ANY);
+ }
+
+ //Launching the camera
+ public void launchCamera(View view){
+ Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
+ //Take a picture and pass results along to onActivityResult
+ startActivityForResult(intent, REQUEST_IMAGE_CAPTURE);
+ }
+
+ //If you want to return the image taken
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+ if(requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK){
+ //Get the photo
+ Bundle extras = data.getExtras();
+ Bitmap photo = (Bitmap) extras.get("data");
+ buckysImageView.setImageBitmap(photo);
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/Android_Beginners/061-062 Notifications/61 to 62 Notifications.txt b/Android_Beginners/061-062 Notifications/61 to 62 Notifications.txt
new file mode 100644
index 0000000..79b4ace
--- /dev/null
+++ b/Android_Beginners/061-062 Notifications/61 to 62 Notifications.txt
@@ -0,0 +1,71 @@
+[source code] Android Development Tutorial - 61 & 62 Notifications
+/* API23 WARNING
+ * This activity was created with API21 when ActioinBarActivity was not depreciated.
+ * IF you are using API23 or later then you will need to extend AppCompatActivity
+*/
+
+
+package your.package.name
+****** activity_main.xml
+
+
+
+
+
+
+***** MainActivity.java
+
+package com.thenewboston.notification;
+
+import android.app.NotificationManager;
+import android.app.PendingIntent;
+import android.content.Intent;
+import android.support.v4.app.NotificationCompat;
+import android.support.v7.app.ActionBarActivity;
+import android.os.Bundle;
+import android.view.View;
+
+public class MainActivity extends ActionBarActivity {
+
+ NotificationCompat.Builder notification;
+ private static final int uniqueID = 45612;
+
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+
+ notification = new NotificationCompat.Builder(this);
+ notification.setAutoCancel(true);
+ }
+
+ public void buckysButtonClicked(View view){
+ //Build the notification
+ notification.setSmallIcon(R.drawable.ic_launcher);
+ notification.setTicker("This is the ticker");
+ notification.setWhen(System.currentTimeMillis());
+ notification.setContentTitle("Here is the title");
+ notification.setContentText("I am the body text of your notification");
+
+ Intent intent = new Intent(this, MainActivity.class);
+ PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
+ notification.setContentIntent(pendingIntent);
+
+ //Builds notification and issues it
+ NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
+ nm.notify(uniqueID, notification.build());
+
+ }
+
+}
\ No newline at end of file
diff --git a/Android_Beginners/063-064 Styles and Themes/63 to 64 Styles and Themes.txt b/Android_Beginners/063-064 Styles and Themes/63 to 64 Styles and Themes.txt
new file mode 100644
index 0000000..9104747
--- /dev/null
+++ b/Android_Beginners/063-064 Styles and Themes/63 to 64 Styles and Themes.txt
@@ -0,0 +1,150 @@
+[source code] Android Development Tutorial - 65 & 66 Shared Preferences
+
+/* Had to troubleshoot App Stopping
+ * Due to my theme not using the correct parent for an appComptActivity.
+ *
+ * These files were created with API 21 and may require setting changes to work with API23
+/*
+***** MainActivity.java
+package your.package.nbv63styles_themes;
+
+import android.support.v7.app.AppCompatActivity;
+import android.os.Bundle;
+import android.view.Menu;
+import android.view.MenuItem;
+
+public class MainActivity extends AppCompatActivity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.menu_main, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ // Handle action bar item clicks here. The action bar will
+ // automatically handle clicks on the Home/Up button, so long
+ // as you specify a parent activity in AndroidManifest.xml.
+ int id = item.getItemId();
+
+ //noinspection SimplifiableIfStatement
+ if (id == R.id.action_settings) {
+ return true;
+ }
+
+ return super.onOptionsItemSelected(item);
+ }
+}
+
+
+***** activity_main.xml
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+***** manifest
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+***** Ocean.xml
+
+
+
+
+
+
+***** greenTheme.xml
+
+
+
+ #009900
+
+
+
+
+
+**** styles.xml (for reference)
+
+
+
+
+
+
diff --git a/Android_Beginners/065-066 Shared Preferences/65 to 66 Shared Preferences.txt b/Android_Beginners/065-066 Shared Preferences/65 to 66 Shared Preferences.txt
new file mode 100644
index 0000000..e432cd5
--- /dev/null
+++ b/Android_Beginners/065-066 Shared Preferences/65 to 66 Shared Preferences.txt
@@ -0,0 +1,134 @@
+[source code] Android Development Tutorial - 65 & 66 Shared Preferences
+
+***** MainActivity.java
+
+package your.package.nbv63preferences;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.support.v7.app.AppCompatActivity;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.EditText;
+import android.widget.TextView;
+import android.widget.Toast;
+
+
+public class MainActivity extends AppCompatActivity {
+ EditText userName;
+ EditText password;
+ TextView dataView;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+
+ userName = (EditText) findViewById(R.id.userNameInput);
+ password = (EditText) findViewById(R.id.passwordInput);
+ dataView = (TextView) findViewById(R.id.dataTextView);
+
+ }
+ // Lesson 64
+ //Save login info
+ public void saveData(View view){
+ SharedPreferences loginData = getSharedPreferences("userInfo", Context.MODE_PRIVATE);
+ SharedPreferences.Editor editor = loginData.edit();
+ editor.putString("userName", userName.getText().toString());
+ editor.putString("password", password.getText().toString());
+ editor.apply();
+
+ Toast.makeText(this,"Saved",Toast.LENGTH_LONG).show();
+ }
+
+ public void getData(View view){
+ SharedPreferences loginData = getSharedPreferences("userInfo", Context.MODE_PRIVATE);
+ String name = loginData.getString("userName", "");
+ String pw = loginData.getString("password","");
+ String msg = "Saved User Name: " + name + "\nSaved Password: " + pw;
+ dataView.setText(msg);
+ }
+}
+
+***** activity_main.xml
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/README.md b/README.md
index 20a0a12..102dd77 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-####Source Code from thenewboston Tutorials
+## Source Code from thenewboston Tutorials
We are in the process of adding the source code from all of the tutorials to a public GitHub repository. If anyone would like to contribute, please feel free!
@@ -10,19 +10,19 @@ DigitalOcean: https://docs.google.com/document/d/1xOllgXRN10fWz1TsURh0OYI60TAVz0
***
-#####How to Submit Source Code
+## How to Submit Source Code
1 - Download [GitHub for Windows](https://windows.github.com/) or [GitHub for Mac](https://mac.github.com/)
-2 - On the top right of this page, click "Fork". This will create a copy for you.
+2 - On the top right of this page, click "Fork". This will create a copy of the repository for you.

-3 - Once your copy has been created, click “Clone in Desktop” to download and save it on your computer.
+3 - Once your copy has been created, click “Clone in Desktop” to download and save it to your computer.

-4 - From here you can make changes, add folders, add source code files, etc...
+4 - From here you can make changes, add folders, add source code files, etc.
5 - When you are finished with your changes, open GitHub for Windows (or Mac)
@@ -40,4 +40,4 @@ DigitalOcean: https://docs.google.com/document/d/1xOllgXRN10fWz1TsURh0OYI60TAVz0
9 - On this page, click the “Create pull request” button.
-10 - Add a comment and click “create pull request” again button to submit.
+10 - Add a comment and click “create pull request” button to submit.