diff --git a/Android_Beginners/010_States of an Activity/MainActivity.java b/Android_Beginners/010_States of an Activity/MainActivity.java new file mode 100644 index 0000000..9885431 --- /dev/null +++ b/Android_Beginners/010_States of an Activity/MainActivity.java @@ -0,0 +1,97 @@ +package com.apps.gabothekiller.myapplication; + +import android.support.v7.app.ActionBarActivity; +import android.os.Bundle; +import android.view.Menu; +import android.view.MenuItem; +import android.util.Log; + +public class MainActivity extends ActionBarActivity { + + private static final String TAG = "buckysMessage"; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + Log.i(TAG, "onCreate"); + } + + @Override + protected void onStart() { + super.onStart(); + Log.i(TAG, "onStart"); + } + + + @Override + protected void onResume() { + super.onResume(); + Log.i(TAG, "onResume"); + } + + + @Override + protected void onPause() { + super.onPause(); + Log.i(TAG, "onPause"); + } + + + @Override + protected void onStop() { + super.onStop(); + Log.i(TAG, "onStop"); + } + + + @Override + protected void onRestart() { + super.onRestart(); + Log.i(TAG, "onRestart"); + } + + + @Override + protected void onDestroy() { + super.onDestroy(); + Log.i(TAG, "onDestroy"); + } + + + @Override + protected void onSaveInstanceState(Bundle outState) { + super.onSaveInstanceState(outState); + Log.i(TAG, "onSaveInstanceState"); + } + + + @Override + protected void onRestoreInstanceState(Bundle savedInstanceState) { + super.onRestoreInstanceState(savedInstanceState); + Log.i(TAG, "onRestoreInstanceState"); + } + + + @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/010_States of an Activity/activity_main.xml b/Android_Beginners/010_States of an Activity/activity_main.xml new file mode 100644 index 0000000..2b1db79 --- /dev/null +++ b/Android_Beginners/010_States of an Activity/activity_main.xml @@ -0,0 +1,20 @@ + + + + + diff --git a/Android_Beginners/021-022_Gestures App/MainActivity.java b/Android_Beginners/021-022_Gestures App/MainActivity.java new file mode 100644 index 0000000..7d6f7ae --- /dev/null +++ b/Android_Beginners/021-022_Gestures App/MainActivity.java @@ -0,0 +1,113 @@ +package com.thenewboston.swiperdiaper; + +import android.support.v7.app.ActionBarActivity; +import android.os.Bundle; +import android.view.Menu; +import android.view.MenuItem; +import android.widget.TextView; +import android.view.MotionEvent; +import android.view.GestureDetector; +import android.support.v4.view.GestureDetectorCompat; + + +public class MainActivity extends ActionBarActivity implements GestureDetector.OnGestureListener, +GestureDetector.OnDoubleTapListener { + private TextView buckysMessage; + private GestureDetectorCompat gestureDetector; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + + buckysMessage = (TextView) findViewById(R.id.buckysMessage); + this.gestureDetector = new GestureDetectorCompat(this, this); + gestureDetector.setOnDoubleTapListener(this); + } + + ///////// GESTURE METHODS ////////// + @Override + public boolean onSingleTapConfirmed(MotionEvent e) { + buckysMessage.setText("onSingleTapConfirmed"); + return true; + } + + @Override + public boolean onDoubleTap(MotionEvent e) { + buckysMessage.setText("onDoubleTap"); + return true; + } + + @Override + public boolean onDoubleTapEvent(MotionEvent e) { + buckysMessage.setText("onDoubleTapEvent"); + return true; + } + + @Override + public boolean onDown(MotionEvent e) { + buckysMessage.setText("onDown"); + return true; + } + + @Override + public void onShowPress(MotionEvent e) { + buckysMessage.setText("onShowPress"); + + } + + @Override + public boolean onSingleTapUp(MotionEvent e) { + buckysMessage.setText("onSingleTapUp"); + return true; + } + + @Override + public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { + buckysMessage.setText("onScroll"); + return true; + } + + @Override + public void onLongPress(MotionEvent e) { + buckysMessage.setText("onLongPress"); + + } + + @Override + public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { + buckysMessage.setText("onFling"); + return true; + } + + ///////// GESTURE METHODS ////////// + + + @Override + public boolean onTouchEvent(MotionEvent event) { + this.gestureDetector.onTouchEvent(event); + return super.onTouchEvent(event); + } + + @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/021-022_Gestures App/activity_main.xml b/Android_Beginners/021-022_Gestures App/activity_main.xml new file mode 100644 index 0000000..7da4044 --- /dev/null +++ b/Android_Beginners/021-022_Gestures App/activity_main.xml @@ -0,0 +1,16 @@ + + + + diff --git a/Android_Beginners/037_SendingBroadcastIntents/MainActivity.java b/Android_Beginners/037_SendingBroadcastIntents/MainActivity.java new file mode 100644 index 0000000..72b66e6 --- /dev/null +++ b/Android_Beginners/037_SendingBroadcastIntents/MainActivity.java @@ -0,0 +1,48 @@ +package com.thenewboston.sendbroadcast; + +import android.support.v7.app.ActionBarActivity; +import android.os.Bundle; +import android.view.Menu; +import android.view.MenuItem; +import android.content.Intent; +import android.view.View; + + +public class MainActivity extends ActionBarActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + } + + public void sendBroadcast(View view){ + Intent i = new Intent(); + i.setAction("com.thenewboston.sendbroadcast"); + i.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); + sendBroadcast(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); + } +} diff --git a/Android_Beginners/037_SendingBroadcastIntents/activity_main.xml b/Android_Beginners/037_SendingBroadcastIntents/activity_main.xml new file mode 100644 index 0000000..b6dbb84 --- /dev/null +++ b/Android_Beginners/037_SendingBroadcastIntents/activity_main.xml @@ -0,0 +1,19 @@ + + +