Default Befaviors

Street Names
isStreetNamesEnabled()
setStreetNamesEnabled(boolean)
Zoom Gestures
isZoomGesturesEnabled
setZoomGesturesEnabled(boolean)
User Navigation
isUserNavigationEnabled
setUserNavigationEnabled(boolean)

@Override
public void onStreetViewPanoramaReady(StreetViewPanorama panorama){

	panorama.setPosition(new LatLng(37.400546,-112.108668));
	panorama.setStreetNamesEnabled(false);
	StreetViewPanoramaCamera camera = new StreetViewPanoramaCamera.Builder()
		.bearing(180)
		.build();
	panorama.animateTo(camera,1000);
}

User Interaction
Detect Camera Changes
setOnStreetViewPanoramaCameraChangeList
Detect User Touches on Panorama
setOnStreetViewPanoramaClickListener
Detect Changes to the Panorama
setOnStreetViewPanoramaChangeListener

Adding a Polyline

PolylineOptions().geodesic(true).add(LatLng);
PolylineOptions().geodesic(true).add(LatLng)
								.add(LatLng)
								.add(LatLng)
								.add(LatLng);

Use a streetViewPanoramaFragment

<fragment
	android:name="com.google.adroid.gms.maps.StreetViewPanoramaFragment"
	android:id="@+id/streetviewpanorama"
	android:layout_width="match_parent"
	android:layout_height="match_parent" />

StreetView Main Activity
Edit Activity
Implement OnStreetViewPanoramaReadyCallback
In OnCreate
Create a StreetViewPanoramaFragment Object
Call .getStreetViewPanoramaAsync(this) on it
Override onStreetViewPanoramaReady
Parameter: StreetViewPanorama
setPosition() for Location
Create a StreetViewPanoramaCamera
animate To(camera, ms)

@Override
prtected void onCreate(Bundle savedInstanceState){
 StreetViewPanoramaFragment StreetViewPanoramaFragment
  (StreetViewPanoramaFragment) getFragmentManager()
  	.findFragmentById(R.id.streetviewpanorama);

  	streetViewPanoramaFragment.getStreetViewPanoramaAsync(this);
 }

@Override
public void onStreetViewPanoramaReady(StreetViewPanorama panorama){

	panorama.setPosition(new LatLng(36.0579667,-112.1430996));
	StreetViewPanoramaCamera camera = new StreetViewPanoramaCamera.Builder()
		.bearing(180)
		.build();
	panorama.animateTo(camera,1000);
}

Using MarkerOptions

MarkerOptions class
position property takes a LatLng
title property takes a string

MarkerOptions renton =
	new MarkerOptions()
		.position(new LatLng(47.89805,-122.120502))
		.title("renton");
renton = new MarkerOptions()
	.position(new LatLng(47.48905, -122.120502))
	.title("Renton");
renton = new MarkerOptions()
	.position(new LatLng(47.48905, -122.120502))
	.title("Renton")
	.icon(BitmapDescriptorFactory.fromResource(
		R.drawable.ic_launcher));

Camera Position

Target, Zoom, Bearing, Tilt
class code: CameraPosition

CameraPosition cp=CameraPosition.builder()
	.target(LatLong)
	.zoom(val)
	.bearing(val)
	.tilt(val)
	.build();

	map.moveCamera(CameraUpdateFactory.newCameraPosition(cp));

	map.animateCamera(CameraUpdateFactory.newCameraPosition(cp),
		<time in ms>, <callback function>);

Making the map move
Seattle: 47.6204, -122.3491
New York: 40.7127, 74.0059
Dublin: 53,3478, 6.2597

Create and Configure the App

1. Create Blank Activity App
2. Edit build.grade
3. Edit Android.manifest
– meta for Google Service
– meta for API key
– permissions for internet, network state and write external storage
– meta for OpenGL

activity_main.xml

<fragment xmlns:android="http://schemas.android.com/apk/res/android"
	android:id="@+id/map"
	andorid:layout_width="match_parent"
	android:layout_height="match_parent"
	android:name="com.google.anroid.gms.maps.MapFragment"/>

Getting the SHA1 key for android

Find android Directory on computer
Then run Keytool command

~$ cd ~/ .android
.android$ keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android

Setting Up Maps
-set up billing
-create a project
-enable maps API
-set up credential

Google Developer Console
https://console.cloud.google.com/

Billing Account Steps
-Name the account
-Specify country for the Account
-Account Type: Business or Individual
-Payer Detail
-Payment Type

Pick Google Maps Android API “Enable”

No More Crash!

Pay attention to any information provided when the application crashes!

@IBAction func dismissSettingsTouched(sender:
	AnyObject){
		self.dismissViewControllerAnimated(true, completion: nil)
	}

@IBAction func bugTypeSelected(sender: UIButton){
	bugFactory.currentBugType = BugFactory.BugType
	(rawValue: sender.currentTitle!.toInt()!)!
	self.dismissViewControllerAnimated(true, completion: nil)
}
println("starting bug work")
for bug in bugs {
	println("done with \(bug)")
}
println("ending bug work")
let log = XCGLogger()
log.setup(logLevel: .Debug, showLineNumbers: true)
log.debug("starting bug work")
for bug in bugs {
	log.verbose("done with \(bug)")
}
log.debug("ending bug work")
import UIKit
class BreakpointBugViewController: UIViewController {
	// MARK: Properties

	let bugFactory = BugFactory.sharedInstance()
	let maxBugs = 0
	let moveDuration = 3.0
	let disperseDuration = 1.0

	var bugs = [UIImageView]()
}
extension BreakpointBugViewController {
	override func canBecomeFirstResponder() ->
		Bool { return true }
	override func motionEnded(motion: UIEventSubtype, withEvent evnt: UIEvent)
	{
		if motion == .MotionShake {
			disperseBugsAnimation()
		}
	}
	func handleSingleTap(recognizer:
		UITapGestureRecognizer){
		addBugToView()
		addBugToView()
		}
}

Geofencing

GoogleAPIClient, GeoFence(Latitude, Longitude, Radius, Expiration)
ArrayList -> GeoFencingRequest (addGeoFences)

create a new App in Android Studio
add the services libraries to buildgradle
edit App.manifest to use the service libraries

edit layout.xml file
add an onClick Handler to this button
call it ‘addGeofencesButtonHandler’

create a GeoFenceTransitionsIntentService class extends IntentService
Add constructor and onCreate() overrides
create onHandleIntent override take Intent as parameter, return void

onHandleIntent(Intent intent) method
Get geofence data from the intent
check for Errors!

onHandleIntent(Intent intent) method
Get the transition type
1. for Enter
2. for Exit

List<Geofence> triggeringGeofences = geofencingEvent

write a sendNotification helper method it should take a string and send a notification with that string

public final class Constant {
	private Constants(){
	}
}

public static final HashMap<String, LatLng> BAY_AREA_LANDMARKS =
	new HashMap<String, LatLng();>
		static {}
private GeofencingRequest getGeofencingRequest(){
}

private PendingIntent getGeofencePendingIntent(){
	Intent intent = new Intent();
	return PendingIntent.getService();
}

Building onReceive()

Received a Context and an Intent
ArrayList
getParcelableArrayListExtra()
Iterate throught ArrayList
– getType() -DetectedActivity code
– getConfidence()

Setting up the Client
onStart()/ onStop()
onPause()
Get LocalBroadcastManager and Unregister our receiver
onResume()
Get LocalBroadcastManager and register our receiver
Use same IntentFilter name(BROADCAST_ACTION)

@Override
protected void onStart(){
	super.onStart();
	mGoogleApiClient.connect();
}

@Override
protected void onStop(){
	super.onStop();
	mGoogleApiClient.disconnect();
}

Implementing Buttons
requestActivityUpdatesButtonHandler
.requestActivityUpdates()
The API Client, Interval in ms
A Pending Intent – getActivityDetectionPendingIntent()
removeActivityUpdatesHandler
.removeActivityUpdates()
API Client & Pending Intent

Asynchronous Stuff

Using IntentService

Activity: StartService
onHandleIntent IntentService

package lmoroney.com.hogeactivity;

import android.app.IntentService;

public class DetectedActivitiesIntentService {
	protected statid final String TAG = "detection_is";
	public DetectedActivitiesIntentService(){
		// Use the TAG to name the worker thread.
		super(TAG);
	}
}

Get ActivityRecognitionResult
Use .getProbableActivities() to get Array
create a new Intent to send results
Add activities to Intent
Use a LocalBroadcastManager

Editing the Main Activity
on the class declaration
implement onConnectionCallbacks
and onConnectionFailedLsitener
Within the Class
Implement onConnected
Implement onConnectionSuspended
Implement onConnectionFailed

public class MainActivity extends ActionBarActivity
	implements GoogleApiClient.ConnectionCallbacks,
	GoogleApiClient.OnConnectionFailedListener {

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

	@Override
	public void onConnected(Bundle connectionHint){	
	}

	@Override
	public void onConnectionFailed(ConnectionResult result){
	}
}

The Receiver Class
class that extends BroadcastReceiver
works best as a nested class on MainActivity
Create ActivityDetectionBroadcastReciever
– make it nested
– extends BroadcastReceiver
– Override onReceive(Context, Intent

public class ActivityDetectionBroadcastReceiver extends BroadcastReceiver {
	protected static final String TAG = "receiver";

	public void onReceiver(Context context, Intent intent){
	
	}
}