Droidcon: Sean Owen: Driving Downloads via Intents- 29/10/2010

1,303 views

Published on

Using intents, Apps can be used like a library or API. This can be a powerful way to drive downloads for some applications.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,303
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • Who has Barcode Scanner on their phone?
  • Droidcon: Sean Owen: Driving Downloads via Intents- 29/10/2010

    1. 1. Sean Owen Co-author “Barcode Scanner” Droidcon 2010 29 October 2010
    2. 2.  Google NYC 20% project, 2 people, from early 2007  Born as part of PrintAds  Released as ZXing open source project  Just a demo app for cameraAPI in Android 1.0
    3. 3.  CameraAPI  Preview, SurfaceView  Focus, zoom, etc.  Fast image processing  Read/write contacts, bookmarks  Wi-fi configuration …  Intents  Web – App integration
    4. 4.  < 1 person project  10.3M installs, 6M active  Growing ~33K per day  #8 Android Market app  Powers (directly or indirectly) most barcode apps for iPhone, Android and RIM … 1 rating : ~100 installs
    5. 5.  Makes Barcode Scanner a dependency  Dependency drives downloads!
    6. 6. (Developers only!)
    7. 7. Intent (ARG1, ARG2, …) Intent (RES1, RES2, …) setResult() startActivityForResult()
    8. 8. <activity ...> ... <intent-filter> <action android:name=“com.myapp.DO_IT”/> <category android:name=“ android.intent.category.DEFAULT”/> </intent-filter> ... </activity>
    9. 9. static final int DO_IT_RESULT = 0xDEADBEEF; Intent doIt = new Intent(“com.myapp.DO_IT”); doIt.addCategory(Intent.CATEGORY_DEFAULT); doIt.putExtra(“ARG1”, arg1); startActivityForResult(doIt, DO_IT_RESULT);
    10. 10. public void onResume() { Intent intent = getIntent(); String action = intent.getAction(); if (“com.myapp.DO_IT”.equals(action))) { String arg1 = intent.getStringExtra(“ARG1”); // Do that something ... } ... }
    11. 11. Intent reply = new Intent(action); // Put result values as Intent “extras” reply.putExtra(“RES1”, res1); reply.putExtra(“RES2”, res2); setResult(RESULT_OK, reply); finish();
    12. 12. public void onActivityResult( int request, int result, Intent reply) { if (request == DO_IT_REQUEST && result == RESULT_OK) { String res1 = reply.getExtra(“RES1”); String res2 = reply.getExtra(“RES2”); // Process result ... } }
    13. 13.  ActivityNotFoundException on startActivityForResult() if app is not installed  Caller sends user to Market to download instead  Provide code and examples so caller gets it right (see android-integration/)
    14. 14. startActivityForResult(...); } catch (ActivityNotFoundException anfe) { // Prompt user with AlertDialog // If user clicks “Yes”: Uri uri = Uri.parse( "market://search?q=pname:com.myapp"); Intent intent = new Intent(Intent.ACTION_VIEW, uri); startActivity(intent); }
    15. 15. <activity ...> ... <intent-filter> <action android:name=“android.intent.action.VIEW”/> <category android:name=“ android.intent.category.DEFAULT”/> <category android:name=“ android.intent.category.BROWSABLE”/> <data android:scheme="http” android:host=”myapp.com” android:path="/doIt"/> </intent-filter> ... </activity>
    16. 16. <a href=“http://myapp.com/doIt?ARG1=arg”> Do it</a> Return informational page at http://myapp.com/doIt ; automatically shows when app not yet installed! MyApp!
    17. 17. public void onResume() { Intent intent = getIntent(); String ds = intent.getDataString(); if (ds.startsWith( “http://myapp.com/doIt”) { Uri uri = Uri.parse(ds); String arg1 = uri.getQueryParameter(“ARG1”); // Do that something } ... }
    18. 18. Uri uri = Uri.parse( “http://myapp.com/doneIt?RES1=res”); Intent reply = new Intent( Intent.ACTION_VIEW, Uri.parse(uri)); startActivity(reply); finish();
    19. 19. http://myapp.com/doneIt?RES1=res1&RES2=res2 RESULTS res1 res2
    20. 20.  Exposing an API can “leak” permissions  Example: App which retrieves contacts via Intent  Then any app can read contacts (without Android permission)!  Think about abuses  Is API consistent with users’ permission expectations?
    21. 21.  Can’t open source? Open an API  API doesn’t have to mean free  “Open” looks good and is good  If you don’t, someone will 1
    22. 22.  Think platform, not just app  Platforms get preinstalled  Platforms are hard to uninstall  Foothold for other services 2
    23. 23.  Drive downloads – and hence users  Download is most of the battle  Users try what’s on the phone  Users stick with what they know 3
    24. 24.  code.google.com/p/zxing  groups.google.com/group/zxing  Barcode Scanner in Android Market

    ×