Banner Ad

package com.example.adviewer;

import ...

public class BannerActivity extends Activity {
	private AdView mAdView;

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

		mAdView = (AdView) findViewById(R.id.adView);
		AdRequest adRequest = new AdRequest.Builder()
			.build();
		mAdView.loadAd(adRequest);
	}
}

AdListener
public void onAdLoaded()
public void onAdFailedToLoad(int code) {AdRequest Error}
public void onAdOpened()
public void onAdLeftApplication() (e.g. BROWSER)

AdMob

Easy to Launch, Long Term, User Value
Paid Donwloads: no, no, yes
Subscription: no, yes, yes
Displaying ADs: yes, yes, yes
In-app purchase: yes, yes, yes

Common Monetization Models
-ADs & In-app purchases, subscription & in-app purchases, paid download & in-app purchases

USERS -> APPS(publishers) -> AdMob -> ADVERTISERS
https://www.google.co.jp/admob/

Types of ADs
-Banner ADs: TEXT, Image
-Interstitional ADs: Text, image, video
-Native ADs

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout
	xmlns:android="http://schemas.android.com/apk/res/android"
	xmlns:ads="http://schemas.android.com/apk/res-auto"
	android:id="@+id/mainLayout"
	android:layout_width="match_parent"
	android:layout_height="match_parent">

	<com.google.android.gms.ads.AdView
		android:id="@+id/adView"
		android:layout_width="match_parent"
		android:layout_height="wrap_content"
		android:layout_alignParentBottom="true"
		android:layout_alignParentLeft="true"
		ads:adSize="BANNER"
		ads:adUnitId="cp-app-pub-xxxx/xxxx"/>
</RelativeLayout>

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();
}