Neurodevelopmental disorders according to the dsm 5 tr
Lecture 12 - Maps, AR_VR_aaaaHardware.pptx
1. Lecture 12/13 - Maps and Speech,
Mini Lectures (AR/VR/Hardware)
CIS 195 - Android App Development
2. Final Project Deliverable
• Final Project Application - Due 4/28 at 11:59 PM EDT
• https://www.seas.upenn.edu/~cis195/android/project.html
• Deliverables:
– Zip Folder including all code
– Help_log.txt (-5 if not included)
– Readme.txt (-5 if not included)
• Include description of what your project is, as well as the
features (points) you chose to implement
3. Agenda
• Google Maps API
• Speech Recognition
• Kotlin Stats
• Non-Native Android Development
• Monetization
• Other Forms of Android
• Sensors
• VR/AR
5. Google Maps for Android
https://developers.google.com/maps/documentation/android-sdk/intro
Before: Make sure google services is set up:
https://developers.google.com/android/guides/setup
• Make sure your emulator supports Google Play API
Step 1: Create Google Maps Activity
Step 2: Get Google Maps API
10. In MapsActivity
override fun onMapReady(googleMap: GoogleMap) {
mMap = googleMap
// Add a marker in Sydney and move the camera
val sydney = LatLng(-34.0, 151.0)
mMap.addMarker(MarkerOptions().position(sydney).title("Marker in Sydney"))
mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney))
}
11.
12. Get Location: First Check for Permissions
private fun setUpMap() {
if (ActivityCompat.checkSelfPermission(this,
android.Manifest.permission.ACCESS_FINE_LOCATION) !=
PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this,
arrayOf(android.Manifest.permission.ACCESS_FINE_LOCATION), 123)
return
}
}
The code above checks if the app has been granted the
ACCESS_FINE_LOCATIONpermission. If it hasn’t, then request it from the user.
13. Get Current Location
First, have your activity class extend the following:
class MapsActivity : AppCompatActivity(), OnMapReadyCallback,
GoogleMap.OnMyLocationButtonClickListener, GoogleMap.OnMyLocationClickListener
Second, call setUpMap() within onMapReady()
Third, add these lines to setUpMap:
mMap.isMyLocationEnabled = true
mMap.setOnMyLocationButtonClickListener(this);
mMap.setOnMyLocationClickListener(this);
14. Override the following functions
override fun onMyLocationClick(location: Location) {
Toast.makeText(this, "Current location:n" + location, Toast.LENGTH_LONG).show()
}
override fun onMyLocationButtonClick(): Boolean {
Toast.makeText(this, "MyLocation button clicked", Toast.LENGTH_SHORT).show()
// Return false so that we don't consume the event and the default behavior still occurs
// (the camera animates to the user's current position).
return false
}
21. Initialize Places In Your Activity
// Initialize Places
Places.initialize(getApplicationContext(), getString(R.string.google_maps_key))
// Create a new Places client instance.
val placesClient = Places.createClient(this)
23. Initialize the Autocomplete Fragment
// Initialize the AutocompleteSupportFragment.
val autocompleteFragment = supportFragmentManager.findFragmentById(R.id.search_text) as
AutocompleteSupportFragment?
// Specify the types of place data to return.
autocompleteFragment!!.setPlaceFields(Arrays.asList(Place.Field.ID, Place.Field.NAME))
// Set up a PlaceSelectionListener to handle the response.
autocompleteFragment.setOnPlaceSelectedListener(object : PlaceSelectionListener {
override fun onPlaceSelected(place: Place) {
// TODO: Get info about the selected place.
Log.i("autocomplete fragment", "Place: " + place.name + ", " + place.id)
}
30. Get the speech dialog
private fun promptSpeechInput() {
val intent = Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH)
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, "en-US") // set language
if (intent.resolveActivity(packageManager) != null) {
startActivityForResult(intent, 10) // start activity
} else {
Toast.makeText(this, "Your Device Don't Support Speech Input", Toast.LENGTH_SHORT).show()
}
}
31. Get the text results
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (requestCode == 10) {
if (resultCode == Activity.RESULT_OK && null != data) {
var result = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS)
search_text.setText(result[0]) // set the search bar with the results
}
}
}
34. SpeechRecognizer → Continuously records and
transcribes from speech to text
- A bit creepy, could make a spy app
- https://developer.android.com/reference/android/speech/SpeechRecognizer
MediaRecorder → basic microphone recording
functionality
- https://developer.android.com/guide/topics/media/mediarecorder
39. More with Kotlin?
Kotlin can be “transpiled”
to JavaScript
https://www.youtube.com/watch?v=Vur75HcfyGc
Kotlin Native
https://blog.jetbrains.com/kotlin/2017/04/kotlinnative-tech-
preview-kotlin-without-a-vm/
41. Cordova PhoneGap and React Native
We have been working
in the “Native” world.
But what if your friend
wants to build an
Android app without
learning Kotlin?
Find new friends? Or is
there a compromise?
42. PhoneGap
“PhoneGap is a distribution of
Apache Cordova — coming with a
few tweaks and custom packages —
that you can use for embedding
websites in mobile apps via
WebView. In short: more than a
website, yet not a fully native mobile
app. A hybrid app compromise!”
43. React Native
“For a React Native-powered app is written in JS, like a PhoneGap one,
yet it doesn't just render a webview, but REAL native components
instead!”
44. More Info
PhoneGap: https://phonegap.com/getstarted/
React Native: https://facebook.github.io/react-native/docs/getting-started
Comparison:
https://uxplanet.org/react-native-vs-cordova-phonegap-ionic-etc-2f85d9651605
https://www.optasy.com/blog/phonegap-vs-react-native-which-platform-choose-building-your-mobile-app-and-why
Other options: Ionic, Cordova, Xamarin
46. Monetization/Publishing an App
- Why do people make mobile
apps?
- To improve their mobile development skills
- Create useful products for the public
- Make $$$
- First, we monetize our apps
- Then, we release them publicly
on the Google Play Store
49. Publishing on the Google Play Store
1. Make a Google Play Developer
Account ($25 fee and no ID
check)
2. Create an app listing: upload a
title, description, app icon, app
screenshots, etc.
3. Upload APK (!!!)
4. Wait for approval (very simple
for Android apps)
50. Pushing Out Updates
1. Make sure to keep track of your
changes and back up to git
2. Update version code in
AndroidManifest.xml
3. Insert API keys if not already
included
4. Generate a new, signed APK
5. Upload new APK to the Google
Play Store and include a
description detailing new
features/bug fixes
59. Easy to set up
class SensorActivity : Activity(), SensorEventListener {
private lateinit var sensorManager: SensorManager
private var mLight: Sensor? = null
public override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.main)
sensorManager = getSystemService(Context.SENSOR_SERVICE) as SensorManager
mLight = sensorManager.getDefaultSensor(Sensor.TYPE_LIGHT)
}
60. Override
override fun onAccuracyChanged(sensor: Sensor, accuracy: Int) {
// Do something here if sensor accuracy changes.
}
override fun onSensorChanged(event: SensorEvent) {
// The light sensor returns a single value. Many sensors return 3 values,
one for each axis.
val lux = event.values[0]
// Do something with this sensor value.
}
63. VR / AR
Easier than you might think!
https://developers.google.com/ar/develop/java/quickstart
Android Tutorial:
https://www.raywenderlich.com/408-getting-started-with-arcore-
with-kotlin
https://www.youtube.com/watch?v=zs5RIfiUB8I <- ARKit in 30 min!
Editor's Notes
Introduce the topic. Talk about motivations behind making Android apps and go through the very basic steps of monetizing apps and releasing them on the Google Play Store
Go over the 5 monetization options and talk about the strategy behind using them. Give real world examples as well (i.e. Soundboards, games, Netflix-types apps, utility apps, stores)
Show how one can include ads in their apps. Basically, AdMob gives black box methods that you can insert into your app. You can configure all the properties of these ads through the AdMob and Google Analytics dashboards.
Here, we’ll talk a lot about exporting the APK (other stuff we’ll gloss over because they’re pretty self-explanatory). For #2, we’ll talk about how a strong description and screenshots help attract more users (also SEO-type stuff with AppAnnie)
Pretty standard stuff, I’ll talk about hiding API keys if code is on a public repo (i.e. for PennMobile and other open source projects)