mDevCamp - The Best from Google IO

  • 448 views
Uploaded on

 

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
448
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
8
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. The Best from Google IOOndra Zahradník@ondrazMonday, May 27, 13
  • 2. Agenda• Gradle• Volley• Mobile Backend Starter• Location• Activity Recognition• Games• Google Play Console etc.Monday, May 27, 13
  • 3. Gradle• Dependency mgmt.• Library support• Reuse of code and resources• Build variants• Testing, CI, SCM automation• Use Gradle 1.6 and android plugin 0.4!• Android Studio integrationMonday, May 27, 13
  • 4. Monday, May 27, 13
  • 5. Gradle Build Script//configuration for gradle buildbuildscript {repositories {maven { url http://repo1.maven.org/maven2 }}dependencies {classpath com.android.tools.build:gradle:0.4}}//gradle android pluginapply plugin: android//android DSLandroid {compileSdkVersion 17buildToolsVersion "17.0.0"}Monday, May 27, 13
  • 6. Gradle BuildType• Defines how app is build• Signing, proguard on/off, zipalign• Package name suffixsigningConfigs {inmite {storeFile file("inmite.keystore")keyAlias "inmite_android"}}buildTypes {debug {packageNameSuffix ".debug"versionNameSuffix "-debug"}release {signingConfig signingConfigs.inmite}}Monday, May 27, 13
  • 7. Gradle - Variants• Free vs. Paid• Multi-apk support• Different runtimes,...• Flavors = productFlavors• Multi-flavor variants = flavorGroupsMonday, May 27, 13
  • 8. Gradle Project Structure/src/main/java/eu/inmite.gradle.example/res/drawables/values...AndroidManifest.xml/resources/paid/java.../src/instrumentTestMonday, May 27, 13
  • 9. Gradle Libraries• binary .aar package in existing repos• supports proguard• custom lint rules come later//dependence on an external jar library//configurations - compile, instrumentTestCompile// debugCompile, releaseCompiledependencies {compile files(libs/android-support-v4.jar)compile com.google.guava:guava:14.0.1}Monday, May 27, 13
  • 10. Gradle Tasks• assemble• assembleDebug• assembleRelease• check• deviceCheck• build• cleanMonday, May 27, 13
  • 11. Volley• Typical catches• single-thread• screen rotations = reloading• not using recycled views• Apache HTTP vs. URLConnectionMonday, May 27, 13
  • 12. Volley• Yet another networking library?• 4 threads in background, prioritization• mem/disk cache• request cancellation• !NetworkImageView!• Network layers - OkHttp, URLConnection,ApacheHttp, SPDY,...Monday, May 27, 13
  • 13. Volley - RequestmRequestQueue = ((Application) getApplication()).getRequestQueue();mImageLoader = new ImageLoader(mRequestQueue, new BitmapLRUCache());mRequestQueue.add(new JsonObjectRequest("https://dl.dropboxusercontent.com/u/5296640/a.json",null,new Response.Listener<JSONObject>() {@Overridepublic void onResponse(JSONObject jsonObject) {try {final JSONArray urls = (JSONArray) jsonObject.getJSONArray("images");final String[] data = new String[urls.length()];for (int i = 0; i < urls.length(); i++) {data[i] = urls.getString(i);}mImageAdapter = new ImageAdapter(data);setListAdapter(mImageAdapter);} catch (JSONException e) {Toast.makeText(..., getString(R.string.parse_error), ...).show();}}},null));Monday, May 27, 13
  • 14. Volley - NetworkImageView@Overridepublic View getView(int i, View view, ViewGroup viewGroup) {...final ViewHolder vh = (ViewHolder) view.getTag();vh.iv.setImageUrl(data[i], mImageLoader);return view;}private class ViewHolder {NetworkImageView iv;}Monday, May 27, 13
  • 15. Mobile Backend Starter• No code backend• Google auth built in• Google Cloud Messaging• Continuous queriesMonday, May 27, 13
  • 16. Beyond the Blue Dot• Contextual apps• Fused location provider = sensors in play• ListenersmLocationClient = new LocationClient(this, this, this);mLocationClient.connect();Location location = mLocationClient.getLastLocation();LocationRequest mLocationRequest = LocationRequest.create().setInterval(5000).setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);mLocationClient.requestLocationUpdates(mLocationRequest,mLocationListener);Monday, May 27, 13
  • 17. Beyond the Blue Dot• PendingIntentmLocationClient = new LocationClient(this, this, this);mLocationClient.connect();LocationRequest mLocationRequest = LocationRequest.create().setInterval(5000).setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);PendingIntent pi = PendingIntent.getService(this, 0,new Intent("com.example.location"), 0);mLocationClient.requestLocationUpdates(mLocationRequest, pi);Monday, May 27, 13
  • 18. GeofencingMonday, May 27, 13
  • 19. GeofencingPendingIntent pi = PendingIntent.getService(this, 0, new Intent("com.example.location"), 0);Geofence geofence = new Geofence.Builder().setRequestId("id").setTransitionTypes(Geofence.GEOFENCE_TRANSITION_ENTER).setCircularRegion(10,10,10).setExpirationDuration(1000).build();final List<Geofence> gfcs = new ArrayList<Geofence>();gfcs.add(geofence);mLocationClient.addGeofences(gfcs, pi,new LocationClient.OnAddGeofencesResultListener() {@Overridepublic void onAddGeofencesResult(int i, String[] strings) {if (i != LocationStatusCodes.SUCCESS) {Toast.makeText(MyActivity.this,"Cannot add geofences",Toast.LENGTH_SHORT).show();}}});Monday, May 27, 13
  • 20. Activity Recognition• Riding, walking, cycling, still, tilting// Connect to the ActivityRecognitionServiceActivityRecognitionClient mActivityRecognitionClient =new ActivityRecognitionClient(this, this, this);mActivityRecognitionClient.connect();// Called when a connection to the ActivityRecognitionService//has been established.public void onConnected(Bundle connectionHint) {Intent intent = new Intent(this, MyIntentService.class);PendingIntent callbackIntent =PendingIntent.getService(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);mActivityRecognitionClient.requestActivityUpdates(30000, callbackIntent);}Monday, May 27, 13
  • 21. Game APIMonday, May 27, 13
  • 22. Game API• G+ SSOMonday, May 27, 13
  • 23. Game API• G+ SSO• AchievementsMonday, May 27, 13
  • 24. Game API• G+ SSO• Achievements• LeaderboardsMonday, May 27, 13
  • 25. Game API• G+ SSO• Achievements• Leaderboards• Cloud SaveMonday, May 27, 13
  • 26. Game API• G+ SSO• Achievements• Leaderboards• Cloud Save• MultiplayerMonday, May 27, 13
  • 27. Game API• G+ SSO• Achievements• Leaderboards• Cloud Save• Multiplayer• Works on Android, iOS, Web (except multi)Monday, May 27, 13
  • 28. Game API• G+ SSO• Achievements• Leaderboards• Cloud Save• Multiplayer• Works on Android, iOS, Web (except multi)• Quota 20mil req/day and 5req/sec/userMonday, May 27, 13
  • 29. Google Play ConsoleMonday, May 27, 13
  • 30. Google Play ConsoleMonday, May 27, 13
  • 31. Google Play ConsoleMonday, May 27, 13
  • 32. Google Play ConsoleMonday, May 27, 13
  • 33. Etc.• In-app Purchase• Simpler API for Google Cloud Messaging• Cloud Connection Server = XMPP• Synchronized notifications• Google Play for EducationMonday, May 27, 13
  • 34. Thank You!@ondrazMonday, May 27, 13