android pro tips trilogy
TRANSCRIPT
![Page 1: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/1.jpg)
Wifi: pUp3EkaP
![Page 2: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/2.jpg)
> 2000 members Largest Android Active Community
![Page 3: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/3.jpg)
Jonathan Yarkoni
Android Developer & Advocate
Ironsource
Android Academy Staff
Yonatan Levin
Android Google Developer
Expert
Britt Barak
Android LeadFigure8
Yossi Segev
Android DeveloperColu
Shahar Avigezer
Android DeveloperHello Heart
![Page 4: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/4.jpg)
Community Mentors
![Page 5: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/5.jpg)
What Do We Do?
● Android Fundamentals - NOW
● Android UI / UX - 29/1 !
● Community Hackathon - 9/3 !!!
● Android Performance
● Mentors Program● Active community
![Page 6: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/6.jpg)
![Page 7: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/7.jpg)
![Page 8: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/8.jpg)
+RanNachmany@shed2k
From good to awesome
![Page 9: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/9.jpg)
01Install
![Page 10: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/10.jpg)
01Install
02Launch
Start!
![Page 11: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/11.jpg)
01Install
02Launch
03Look & Feel
Start!
![Page 12: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/12.jpg)
01Install
02Launch
03Look & Feel
04Use
Start!
![Page 13: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/13.jpg)
Step 1: InstallFirst touch point.
![Page 14: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/14.jpg)
![Page 15: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/15.jpg)
![Page 16: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/16.jpg)
![Page 17: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/17.jpg)
Minimize Permissions• Request only core functionality blockers.
![Page 18: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/18.jpg)
Minimize Permissions• Request only core functionality blockers.• You don't need permission to launch another App that has
the permission
![Page 19: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/19.jpg)
Minimize Permissions• Request only core functionality blockers.• You don't need permission to launch another App that has
the permission
![Page 20: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/20.jpg)
Need a contact?
![Page 21: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/21.jpg)
Use the force, Luke
![Page 22: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/22.jpg)
Asking for contact
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);intent.setType(Phone.CONTENT_ITEM_TYPE);startActivityForResult(intent, MY_REQUEST_CODE);
![Page 23: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/23.jpg)
void onActivityResult(int requestCode, int resultCode, Intent data) {
if (data != null) { Uri uri = data.getData(); if (uri != null) { Cursor c = getContentResolver().query(uri, new String[] {Contacts.DISPLAY_NAME,
Phone.NUMBER}, null,null, null) }
}}
Asking for contact
![Page 24: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/24.jpg)
Need a UUID?
Option 1: TelephonyManager.getDeviceIdRequires READ_PHONE_STATE.
Option 2: Settings.Secure.ANDROID_IDReset at wipeFollows the device, not the user.
![Page 25: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/25.jpg)
Use the force, Luke
![Page 26: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/26.jpg)
Generate UUIDUse backup API
![Page 27: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/27.jpg)
Step 2: First Launch“ok, let’s see what this app is all about”
![Page 28: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/28.jpg)
My BigBRAND
![Page 29: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/29.jpg)
LOADING ...
![Page 30: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/30.jpg)
A bunch of data to insert?
![Page 31: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/31.jpg)
SQLTransactions speeds things up
![Page 32: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/32.jpg)
db.beginTransaction();
try{ for(int i=0; i<selectedIds.length; i++){ values.put(COLUMN_ID,selectedIds[i]); values.put(COLUMN_STARRED,starred); db.insert(TABLE_STARRED,null,values); db.yieldIfContendedSafely(); } db.setTransactionSuccessful();}finally { db.endTransaction();}
Bulk DB update
![Page 33: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/33.jpg)
Not fast enough?
![Page 34: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/34.jpg)
Server Side● Create a db file using SQLite and
fill it.● Name your primary key columns
“_id”● Create a table:
“android_metadata”● Insert a single row containing the
locale (ex: "en_US")
Import ready to use DB
![Page 35: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/35.jpg)
Mobile Side● Grab the zipped DB from assets
or network.● Unzip it to your getDatabaseDir()● Use as usual
Import ready to use DB
SQLite version
![Page 36: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/36.jpg)
Step 3: Look & Feel“Where is the share button?”
![Page 37: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/37.jpg)
![Page 38: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/38.jpg)
HOTMAIL
![Page 39: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/39.jpg)
OUTLOOK.COM
![Page 40: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/40.jpg)
HOTMAIL OUTLOOK.COM
![Page 41: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/41.jpg)
Follow the guidelines
![Page 42: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/42.jpg)
LOOK AND FEEL
![Page 43: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/43.jpg)
LOOK AND FEEL
![Page 44: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/44.jpg)
LOOK AND FEEL
![Page 45: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/45.jpg)
LOOK AND FEEL
![Page 46: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/46.jpg)
LOOK AND FEEL
![Page 47: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/47.jpg)
LOOK AND FEEL
![Page 48: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/48.jpg)
Follow the guidelines
Please
![Page 49: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/49.jpg)
Step 4: Daily Use“I really like it, but...”
![Page 50: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/50.jpg)
![Page 51: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/51.jpg)
![Page 52: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/52.jpg)
Always up to dateUsers don't like to wait. • Location updated.• Data downloaded from web.
![Page 53: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/53.jpg)
Always up to dateUsers don't like to wait. • Location updated.• Data downloaded from web.
![Page 54: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/54.jpg)
Find the location fast.• Loop through all providers->getLastKnownLoc.
• If there is one or more location which is recent enough – return the most accurate one
• If not – Return the latest one.• In case of #2 – look for “fastest” provider:
• Coarse Accuracy && low power consumption. • Register for location update.
![Page 55: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/55.jpg)
Use passive location• >Gingerbread. • Passive location – Receive location update when other app is using
location provider. • Requires ACCESS_FINE_LOCATION permission.• Location.getProvider().
![Page 56: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/56.jpg)
Fused Location• Define your priorities • Let Google play services do the heavy lifting.
![Page 57: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/57.jpg)
// Create an instance of GoogleAPIClient.if (mGoogleApiClient == null) { mGoogleApiClient = new GoogleApiClient.Builder(this) .addConnectionCallbacks(this) .addOnConnectionFailedListener(this) .addApi(LocationServices.API) .build();}
Using fused location
![Page 58: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/58.jpg)
@Overridepublic void onConnected(Bundle connectionHint) { //get last known location mLastLocation = LocationServices.FusedLocationApi.getLastLocation( mGoogleApiClient); if (mLastLocation != null) { //do something }
//register for location updates LocationRequest request = LocationRequest.create(); request.setInterval(minTime); request.setPriority(lowPowerMoreImportantThanAccuracy ? LocationRequest.PRIORITY.BALANCED_POWER_ACCURACY : LocationRequest.PRIORITY_HIGH_ACCURACY ); LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, request, this);}
Using fused location
![Page 59: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/59.jpg)
@Overridepublic void onLocationChanged(Location location) { mCurrentLocation = location; mLastUpdateTime = DateFormat.getTimeInstance().format(new Date()); updateUI();}
Using fused location
![Page 60: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/60.jpg)
Data updates
![Page 61: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/61.jpg)
The challenges:• When to update?• Where the data is coming from?• What to update?• How to update?
![Page 62: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/62.jpg)
When to update my App?• Right before the user launches it
• Assuming I have battery.• Assuming I have BW.
![Page 63: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/63.jpg)
Where the data is coming from?• My Server• 3rd Party Servers
![Page 64: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/64.jpg)
Where the data is coming from?• My Server• 3rd Party Servers
![Page 65: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/65.jpg)
What to Update? • What's Hot• Interesting stuff• Other
![Page 66: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/66.jpg)
BG Update
What's Hot
BG Update
Interesting Stuff Other
![Page 67: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/67.jpg)
BG Update
What's Hot
BG Update
Interesting Stuff Other
FCM Embedded
![Page 68: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/68.jpg)
BG Update
What's Hot
BG Update
Interesting Stuff Other
FCM Embedded
FCM + Back-off
![Page 69: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/69.jpg)
BG Update
What's Hot
BG Update
Interesting Stuff Other
FCM Embedded
FCM + Back-off
Daily / Bundled
![Page 70: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/70.jpg)
![Page 71: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/71.jpg)
Being Invisible• I don't need to think how the app works.• I never notice the app's work.• I am never being bothered by the app.
![Page 72: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/72.jpg)
Work OfflineQueue and Send transactions.• Use persistence layer.• Tape From Square.
![Page 73: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/73.jpg)
Work Semi-Offline• Be resilient to poor networks.
• Prioritize your transactions.• Be able to cancel transaction on the fly, or clear the Queue.• Adjust your app’s behavior and timeouts accordingly.
• Use Volley (or any other cool transport layer)
![Page 74: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/74.jpg)
Be efficient – Data usage
![Page 75: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/75.jpg)
![Page 76: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/76.jpg)
Radio Resource• Frequency is expensive. • Cell tower can not service 100% of its clients 100% of the time. • Frequency is dynamically allocated to clients.
• Cellular cells uses various multiplexing methods (OFDM/OFDMA, FTDMA).
![Page 78: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/78.jpg)
Radio State Machine
IDLE
FACH
DCH
Power
Bandwidth
![Page 79: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/79.jpg)
Radio State Machine
IDLE
FACH
DCH
Power
~10Sec tail time
~12-75 Sec tail time
Bandwidth
![Page 80: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/80.jpg)
Avoid bursty traffic• Transmit data “together”.
• Piggyback if needed.• Pre-fetch data for the next 2-5 minutes.
• Don't ping just to keep TCP connection alive• RRC != TCP Connection.• TCP connection is kept even in IDLE mode
![Page 81: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/81.jpg)
#1: Case study: Pandora• Music file streamed as single file.• Analytics data sends ~2KB every 62.5 seconds
Source: AT&T research
![Page 82: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/82.jpg)
#1: Case study: Pandora
0.2% of data consumed 46% of energy!
![Page 83: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/83.jpg)
Don't be HTTP rookie• Don't download what you already have.• Take care of server headers
• Max-age, expires. • Use conditional GET when cache expires
• Use “last modified” header.• Server return 304, with no body.
![Page 84: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/84.jpg)
Don't be lazy• Read AT&T research:
• Top Radio Resources Issues in Mobile Applications• AT&T Lab Research – call for more efficient apps
• Watch my BABBQ talk - Building battery efficient apps • (or ask yonathan to invite me once more ;-) )
• Use ARO.• Developed by AT&T.• Monitors and analyze network activity. • http://developer.att.com/• https://github.com/attdevsupport/ARO
![Page 85: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/85.jpg)
![Page 86: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/86.jpg)
Adaptive App• Optimized for different User Experience.
• User has more than one device. • Be predictable.• Behave as expected
![Page 87: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/87.jpg)
Text Input• Specify the Edit Text input to show the right keyboard type.
• use android:inputType attribute• Four classes of keyboards:
• Plain text• Decimal Number• Phone Number• Date or Time
![Page 88: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/88.jpg)
Text Input• Plain text types:
• URIs• Email address• People's names• Postal address• Passwords
![Page 89: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/89.jpg)
![Page 90: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/90.jpg)
![Page 91: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/91.jpg)
![Page 92: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/92.jpg)
![Page 93: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/93.jpg)
mGeofenceList.add(new Geofence.Builder() // Set the request ID of the geofence. This is a string to identify this // geofence. .setRequestId(entry.getKey())
.setCircularRegion( entry.getValue().latitude, entry.getValue().longitude, Constants.GEOFENCE_RADIUS_IN_METERS ) .setExpirationDuration(Constants.GEOFENCE_EXPIRATION_IN_MILLISECONDS) .setTransitionTypes(Geofence.GEOFENCE_TRANSITION_ENTER | Geofence.GEOFENCE_TRANSITION_EXIT) .build());
Geofencing
![Page 94: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/94.jpg)
private GeofencingRequest getGeofencingRequest() { GeofencingRequest.Builder builder = new GeofencingRequest.Builder(); builder.setInitialTrigger(GeofencingRequest.INITIAL_TRIGGER_ENTER); builder.addGeofences(mGeofenceList); return builder.build();}
Geofencing
![Page 95: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/95.jpg)
private PendingIntent getGeofencePendingIntent() { // Reuse the PendingIntent if we already have it. if (mGeofencePendingIntent != null) { return mGeofencePendingIntent; } Intent intent = new Intent(this, GeofenceTransitionsIntentService.class); // We use FLAG_UPDATE_CURRENT so that we get the same pending intent back when // calling addGeofences() and removeGeofences(). return PendingIntent.getService(this, 0, intent, PendingIntent. FLAG_UPDATE_CURRENT);}
Geofencing
![Page 96: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/96.jpg)
LocationServices.GeofencingApi.addGeofences( mGoogleApiClient, getGeofencingRequest(), getGeofencePendingIntent() ).setResultCallback(this);
Geofencing
![Page 97: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/97.jpg)
private void initTextToSpeech() { Intent intent = new Intent(Engine.ACTION_CHECK_TTS_DATA); startActivityForResult(intent,TTS_DATA_CHECK)}
Geek Magic - Text to speech
![Page 98: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/98.jpg)
private void onActivityResult(int request, int result, Intent data) { if (TTS_DATA_CHECK == request && Engine.CHECK_VOICE_DATA_PASS == result) { tts = new TextToSpeech(this, new on InitListener() { public void onInit(int status) { if (TextToSpeech == status) { ttsIsInit = true; } }
});}else { startActivity(new Intent(Engine.ACTION_INSTALL_TTS_DATA));}
}
Geek Magic - Text to speech
![Page 99: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/99.jpg)
private void say(Strint text) { if (null != tts && ttsIsInit) { tts.speak(text,TextToSpeech.QUEUE_ADD, null); }}
Geek Magic - Text to speech
![Page 100: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/100.jpg)
private void requestVoiceInput() { Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM); intent.putExtra(RecognizerIntent.EXTRA_PROMPT, getString(R.String.voice_input_prompt); intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.ENGLISH); startActivityForResult(intent,VOICE_RECOGNITION);}
Geek Magic - Speech Recognition
![Page 101: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/101.jpg)
private void requestVoiceInput() { Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM); intent.putExtra(RecognizerIntent.EXTRA_PROMPT, getString(R.String.voice_input_prompt); intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.ENGLISH); startActivityForResult(intent,VOICE_RECOGNITION);}
Geek Magic - Speech Recognition
![Page 102: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/102.jpg)
Geek Magic – Speech Recognition• More than one result is returned.• Loop through all results, taking context in mind.
![Page 103: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/103.jpg)
<intent-filter> <action android:name="android.intent.action.VIEW"/> <category android:name="android.intent.category.DEFAULT"/> <data android:host="mysite.com" android:scheme="http"/></intent-filter>
Intercept Links
![Page 104: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/104.jpg)
Follow the guidelines
Be FreshBe InvisibleBe EfficientBe AdaptiveBe Psychic
Make it quick
Start!
minimize permissions
![Page 105: Android pro tips trilogy](https://reader033.vdocuments.mx/reader033/viewer/2022051101/58ed8dee1a28abe0468b46a9/html5/thumbnails/105.jpg)
Thank You!+RanNachmany@shed2k