• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Android 4 - Under the hood
 

Android 4 - Under the hood

on

  • 899 views

Speaker: Lars Röwekamp auf der MobileTechCon 2012 in Frankurt am Main ...

Speaker: Lars Röwekamp auf der MobileTechCon 2012 in Frankurt am Main

Android 4 wird häufig mit der lang ersehnten Angleichung des UI APIs für Smartphones und Tablet PCs gleichgesetzt. Dabei hat die aktuelle Android Version deutlich mehr zu bieten: Social Media API, Visual Voice Mail, Low-Level Video Streaming, Android Beam für NFC und Wifi Direct sind nur einige der neuen Möglichkeiten. Die Session gibt einen Einblick in die neuen Features und zeigt an praktischen Beispielen, wie diese zum Einsatz kommen können.

Statistics

Views

Total Views
899
Views on SlideShare
896
Embed Views
3

Actions

Likes
1
Downloads
0
Comments
0

1 Embed 3

http://www.openknowledge.de 3

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Android 4 - Under the hood Android 4 - Under the hood Presentation Transcript

    • Lars Röwekamp | CIO New Technologies @mobileLarson @_openKnowledgeANDROID 4under the hood
    • User Interface
    • Social
    • Social Sharing
    • be
    • beconnected
    • Gimme
    • Gimme Input
    • Make
    • Make Noise
    • User Interface
    • UI eXtended> Fragments> Loaders> Sorry, not Version 4.x
    • UI eXtendedFragments
    • UI eXtended> Multi-Pane UI
    • UI eXtended> Multi-Pane UI > UI Fragments als „Building Blocks“ > UI Activity Layout als „Block Assembler“ > UI Activity Class als „Block Assembler Logic“ > UI Ressources als „Switch“
    • UI eXtended Was ist ein> Multi-Pane UI > UI Fragments als „Building Blocks“ Fragment? > UI Activity Layout als „Block Assembler“ > UI Activity Class als „Block Assembler Logic“ > UI Ressources als „Switch“
    • UI eXtended> Fragment > Activity Modul a.k.a. Sub Activity > inkl. eigener UI > inkl. eigenem Lifecycle > benötigt immer eine umliegende Activity > Lifecycle passt sich Activity-Lifecycle an
    • UI eXtended> Fragments & Resources > Size: small, normal, large, xlarge > Density: ldpi, mdpi, hdpi, xhdpi > Orientation: landscape, portrait > Designation: sw, w, h, ...dp
    • UI eXtended> Fragments & Resources > Size: small, normal, large, xlarge Deprecated > Density: ldpi, mdpi, hdpi, xhdpi > Orientation: landscape, portrait > Designation: sw, w, h, ...dp Added
    • UI eXtendedOk, aber wie> Fragments & Resources spielt das > Size: small, normal, large, xlarge Deprecated > Density: ldpi, mdpi, hdpi, xhdpi > Orientation: landscape, portraitzusammen? > Designation: sw, w, h, ...dp Added
    • UI eXtended> Fragments in Action
    • UI eXtended> Fragments in Action
    • UI eXtended > Fragments in Action > Starte MainActivity > Screensize Smartphone > Orientierung Portrait 1) > Layout aus /res/layout > Fragment A > Bei Selektion schicke Intent „Details“ > Zeige DetailsActivity mit Fragment B1) Standardlayout
    • UI eXtended > Fragments in Action > Starte DetailsActivity > Screensize Smartphone > Orientierung Portrait 1) > Layout aus /res/layout > Fragment B1) Standardlayout
    • UI eXtended > Fragments in Action > Starte MainActivity > Screensize Tablet > Orientierung Landscape 1) > Layout aus /res/layout-sw600dp > Fragment A und B > Bei Selektion aktualisiere B1) Layout für: smalest witdh 600dp = 10“ Tablet
    • UI eXtended> Fragments Modus-Check // MainActivity: Check, if detail fragment is visible @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ... DetailFragment frag = (DetailFragment) getFragmentManager() .findFragmentById(R.id.detail_fragment); if (frag != null) mDualPane = true; }
    • UI eXtended> Fragments Modus-Weiche // MainActivity: Call detail for selected list item @Override public void onItemSelected(int category, int pos) { if (!mDualPane) { Intent i = new Intent(this, DetailActivity.class); startActivity(i); // Not shown: i.putExtra(...) } else { DetailFragment frag = (ContentFragment) getFragmentManager() .findFragmentById(R.id.detail_fragment); frag.updateContent(category, pos); } }
    • UI eXtended> Fragments Special Features > Transaktionssteuerung via FragmentTransaction > insert(), replace(), delete() via FragmentManager > addToBackStack() erlaubt Verwaltung > Back-Stack erlaubt Navigation via „Back-Button“
    • UI eXtended> Fragments Special Features // Using Fragments and FragmentTransactions Fragment newFragment = new ExampleFragment(); FragmentTransaction transaction = getFragmentManager().beginTransaction(); // Replace, and add the transaction to the back stack transaction.replace(R.id.fragment, newFragment); transaction.addToBackStack(null); // Commit the transaction transaction.commit();
    • UI eXtendedLoader
    • UI eXtended> Loader > asynchrones Laden von Daten > verfügbar in Activities und Fragments > Content-Change-Monitoring der Datensource > Reconnection zu vorheriger Position > CursorLoader (ready to use für ContentProvider) > Loader oder AsyncTaskLoader
    • UI eXtended
    • UI eXtended
    • UI eXtended
    • UI eXtended> Loader // Activity implementing Loader Callbacks public class MyActivity extends Activity implements LoaderManager.LoaderCallback<Cursor> { @Override public void onCreate(Bundle savedInstanceState) {! ! super.onCreate(savedInstanceState); ... adapter = new SimpleCursorAdapter(...) setListAdapter(adapter) getLoaderManager().initLoader(0, null, this); } ...}
    • UI eXtended> Loader // Activity implementing Loader Callbacks public class MyActivity extends Activity implements LoaderManager.LoaderCallback<Cursor> { ... ! // loader was created and is ready to work public Loader<Cursor> onCreateLoader(int id, Bundle args){ // set content provider query URI etc. ... // access content provider return new CursorLoader(this, cpQueryUri, projection, where, whereArgs, sortOrder); } ...}
    • UI eXtended> Loader // Activity implementing Loader Callbacks public class MyActivity extends Activity implements LoaderManager.LoaderCallback<Cursor> { ... ! // loader finished loading - data is available public void onLoadFinished(Loader<Cursor> l, Cursor c){ adapter.swapCursor(c); } // loader was reseted - its data is unavailable public void onLoaderReset(Loader<Cursor> l){ adapter.swapCursor(null); }}
    • UI eXtendedSorry, not 4.x
    • UI eXtended> Sorry, not Version 4.x > WTH? > No problemo! > Android Support Library > a.k.a. Android Compability Library > ab Version 1.6+
    • UI eXtended
    • UI eXtended„Und was ist mit dem ActionBar?“
    • UI eXtended
    • Demo(s)
    • Social Sharing
    • Sharing> Social API> Calendar API> Visual Voicemail API
    • SharingSocial API
    • Sharing„With ICS, we set out to buildsoftware that supports emotionalconnections between humansand the devices they carry.“
    • Sharing> Social API > Speichern/teilen von User Contacts und Content > letzte Aktivitäten, Photos, eMails, Texte, ... > Andere Apps/Social Networks integrierbar > Google+, Facebook, Twitter, Homemade > User Permissions notwendig > Peoples App als Referenz
    • Sharing> Social API > Idee 1: prominentere Darstellung der Kontakte > Idee 2: prominentere Darstellung der Aktivitäten
    • Sharing> Social API > Idee 1: prominentere Darstellung der Kontakte > Idee 2: prominentere Darstellung der Aktivitäten
    • Sharing> Social API > Contact > Raw Contact > Data Row > Sync Adapter > Update Stream
    • Sharing > Social API > Contact > Raw Contact > Data Row > Sync Adapter > Update StreamRawContacts.ACCOUNT_NAMERawContacts.ACCOUNT_TYPEStructuredName.DISPLAY_NAME
    • Sharing > Social API > Contact > Raw Contact > Data Row > Sync Adapter > Update Stream > Recent Activities?RawContacts.ACCOUNT_NAMERawContacts.ACCOUNT_TYPEStructuredName.DISPLAY_NAME
    • Sharing READ-ONLY!> Tables READ-WRITE! READ-WRITE!
    • Sharing > Table Relations
    • Sharing > Table Relations
    • Sharing> Data Structure
    • Sharing> Data Structure
    • Sharing> Connection hinzufügen <!-- sync account description --> <ContactsAccountType   xmlns:android="http://schemas.android.com/..." <!-- invite to add connection -->   inviteContactActivity= "com.example.activities.InviteContactActivity"  inviteContactActionLabel= "@string/invite_action_label"> <!-- Data type declaration --> ... </ContactsAccountType> Sync Adapter Config: ready for „INVITE_CONTACT“ Intents
    • Sharing> SyncAdapter
    • Sharing> SyncAdapter
    • Sharing> Social API > Contact > Raw Contact > Data Row > Sync Adapter > Update Stream (seit API 15+)
    • Sharing> Social API > Contact > Raw Contact > Data Row > Sync Adapter > Update Stream (seit API 15+)
    • Sharing> Add Stream Item // add a stream item to an existing raw contact private void addContactStreamItem(Context context, long rawContactId, String text, String comments, long timestamp, String accountName, String accountType){  ContentValues values = new ContentValues();  values.put(StreamItems.RAW_CONTACT_ID, rawContactId);  values.put(StreamItems.TEXT, "Me at the MTC 2012");  values.put(StreamItems.TIMESTAMP, timestamp);  values.put(StreamItems.COMMENTS, comments);  values.put(StreamItems.ACCOUNT_NAME, accountName);  values.put(StreamItems.ACCOUNT_TYPE, accountType);  context.getContentResolver() .insert(StreamItems.CONTENT_URI, values); }
    • Sharing> Click Stream Item <ContactsAccountType   xmlns:android="http://schemas.android.com/..." <!-- Click on Item Stream -->   viewStreamItemActivity= "com.example.activities.ViewStreamItemActivity” <!-- Click on Item Stream Photo -->   viewStreamItemPhotoActivity= "com.example.activities.ViewStreamItemPhotoActivity"> <!-- Data type declaration --> ... </ContactsAccountType>
    • Demo(s)
    • SharingCalendar API
    • Sharing> Calendar API > Kalenderdienste in eigene Apps integrieren Na > Permissions vorausgesetzt ... > Erzeugen/verwalten von Kalendereinträgen > Dates, Teilnehmer, Alerts, Reminder, ... endlich! > Visualisierung via vorgegebener/eigener UIs > Event Verwaltung, Alerts, Reminders > Calendar App als Referenz
    • Sharing> Calendar API > Kalenderdienste in eigene Apps integrieren > Permissions vorausgesetzt ... > Erzeugen/verwalten von Kalendereinträgen > Dates, Teilnehmer, Alerts, Reminder, ... > Visualisierung via vorgegebener/eigener UIs > Event Verwaltung, Alerts, Reminders > Calendar App als Referenz
    • Sharing > Calendar API
    • Sharing> Calendar API > CalendarContract.Calendar > je Kalender: Name, Farbe, Sync Info, ... > CalendarContract.Event > je Ereignistyp: Titel, Location, Start-/Endzeit, ... > je Ereignis: CalendarContract.Instance > CalendarContract.Attendees > je Teilnehmer: Type und Status
    • Sharing> Calendar API > CalendarContract.Reminders > je Reminder: Typ und Zeitpunkt > CalendarContract.ExtendedProperties > Zusatzinformationen für den SyncAdapter > automatisches Cascading Delete > sonst keine Aktion vom Calender Provider
    • Sharing> Calendar API > In Aktion ... (Quelle: Google Apps Developer Blog)
    • Sharing> Calendar API // Check for existing calender(s) Uri uri = CalendarContract.Calendars.CONTENT_URI; String[] projection = new String[] {       CalendarContract.Calendars._ID,       CalendarContract.Calendars.ACCOUNT_NAME,       CalendarContract.Calendars.CALENDAR_DISPLAY_NAME,       CalendarContract.Calendars.NAME,       CalendarContract.Calendars.CALENDAR_COLOR }; Cursor  calendarCursor  =  managedQuery(uri,projection,                                                                                  null,  null,  null);
    • Sharing> Calendar API // Insert an event - permission needed ContentResolver cr = getContentResolver(); ContentValues cv = new ContentValues(); cv.put(CalendarContract.Events.DTSTART, startDateTime); cv.put(CalendarContract.Events.DTEND, endDateTime); cv.put(CalendarContract.Events.TITLE, "MTC 2012"); cv.put(CalendarContract.Events.DESCRIPTION, "MTC ..."); cv.put(CalendarContract.Events.CALENDAR_ID, 3); Uri uri = cr.insert( CalendarContract.Events.CONTENT_URI, cv); // Retrieve ID for new event String eventID = uri.getLastPathSegment();
    • Sharing> Calendar API // Insert an event via intent - no permission needed      Intent  intent  =  new  Intent(Intent.ACTION_INSERT)          .setType("vnd.android.cursor.item/event")          .putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME,  ...)          .putExtra(CalendarContract.EXTRA_EVENT_END_TIME,  ...)                              .putExtra(CalendarContract.EXTRA_EVENT_ALL_DAY  ,  false)            .putExtra(Events.TITLE,  "MTC  2012")          .putExtra(Events.DESCRIPTION,  "MTC  2012  Android  Special  Day")              ...      startActivity(intent);
    • SharingVisual Voice Mail
    • Sharing> Visual Voice Mail API > Integrieren von „Voice Mails“ > Nachrichten, Aufnahmen, Sound-Dateien ... > Voicemail Content Provider als Bindeglied > eigene App(s) > Phone App via Call Log > Phone App als Referenz
    • Sharing> Visual Voice Mail API
    • Demo(s)
    • beconnected
    • Connectivity> NFC Beam> Wifi Direct> Bluetooth HDP
    • ConnectivityNFC Beam
    • Connectivity> NFC Beam (a.k.a. NDEF Push) > Datenaustausch zwischen 2 NFC Devices > Apps, Contacts, Music, Videos, Game Scores ... > System liefert UI und Low-Level NFC Support > Daten werden ausgetauscht > Text, Uri, „Unknown“ > Daten lösen je nach Typ Aktion aus > Google Play startet auto. falls App nicht vorhanden
    • Connectivity
    • Connectivity> NFC Beam > Sender > „Beam Application“ im Vordergrund > android.permission.NFC > Empfänger > muss „unlocked“ sein > Intent-Filter für „korrekten“ Content
    • Connectivity> NFC Sender - „static Message“ NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(); // set static payload nfcAdapter.setNdefPushMessage(nfcMessage, this); ...
    • Connectivity> NFC Sender - „dynamic Message“ NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(); // set payload just in time of sending nfcAdapter.setNdefPushMessageCallback ( public NdefMessage createNdefMessage(NfcEvent event) { new CreateNdefMessageCallback() { long now = ... String payload = “Beam me up at “ + now; NdefMessage message = createNfcMessage(payload); return message; } }, this); ...
    • Connectivity> NFC Sender - NdefMessage // create NdefMessage for beaming private NdefMessage createNfcMessage(String msg) { String mimeType = “application/de.openknowledge.nfc“; byte[] mimeBytes = mimeType.getBytes(...); return nfcMessage = new NfcMessage( new NdfeRecord[] { // 1. Record with payload ... // 2. Android Application Record ... } };
    • Connectivity> NFC Receiver <intent-filter> <action android:name=“android.nfc.action.NDEF_DICSOVERED“/> <category android:name=“android.intent.DEFAULT“/> <data android:mimeTye=“application/de.openknowledge.nfc“/> </intent-filter>
    • Connectivity> NFC Receiver // Beam data is delivered via intent EXTRA DATA Parcelable[] messages = intent.getPacelableArrayExtra( NfcAdapter.EXTRA_NDEF_MESSAGES); NdefMessage message = (NdfMessage)messages[0]; NdefRecord record = message.getRecords()[0]; String payload = new String(record.getPayload());
    • ConnectivityWifi Direct
    • Connectivity> Wifi Direct > Peer-to-Peer Connections > Peer Discovery, Request und Connecting > WifiP2pManager als Main Player > Listener und Intents als Helper > Google Play Filter > uses-feature „android.hardware.wifi.direct“
    • Connectivity> Wifi Direct
    • Connectivity> Wifi Direct // required permission settings <uses-sdk android:minSdkVersion="14" /> <uses-permission android:name= "android.permission.ACCESS_WIFI_STATE" /> <uses-permission android:name= "android.permission.CHANGE_WIFI_STATE" /> <uses-permission android:name= "android.permission.CHANGE_NETWORK_STATE" /> <uses-permission android:name= "android.permission.INTERNET" /> <uses-permission android:name= "android.permission.ACCESS_NETWORK_STATE" />
    • Demo(s)
    • Gimme Input
    • Input> Text Service API> Voice Input> Input Framework
    • Input> Text Service API > Abfrage von Textservices > Dictionaries, Spell Checker für ... > Wortvorschläge, Autokorrekturen, ... > Pluggable Service > unabhängig vom aktiven InputManager > System liefert (verbesserte) Default Services > können auch Eigenentwicklungen sein
    • Input> Text Service API
    • Input> Voice Input > Speach to Text > verbesserte Voice Input Engine > I18N, Interpunktion, Fehlererkennung, ... > Text to Speach > Neues Framework zur Textumwandlung
    • Input> Input Framewort > Motion Tool Types > Stylus, Finger, Mouse, Eraser inkl. Button Events > Stylus Input Events > Tilt, Distance Axes, Pressure, Moition > Hover Events für View Klasse > onHoverListener für Enter, Exit, Move
    • Demo(s)
    • Make Noise
    • Media> Camera Features> Media Effects> Audio Remote Control> New Media Codecs
    • Media> Camera API Features > Zero Shutter Lag Exposure > Continuous Focus > Stabilized Image Zoom > Full-Resolution Snapshot vom Video > Custom Regions innerhalb von Previews > Face Detection Service liefert Koordinaten
    • Media> Media Effects > Transformation Filter für OpenGL ES 2.0 Textures > Transformation werden durch GPU ausgeführt > Color Level & Brightness > Hintergründe > Linsenverzerrung > Bildschärfe, -ausschnitte, -rotation
    • Media> Audio Remote Control > Playback Controls für Multi-Media Apps > Nutzung via RemoteControllClient > Nutzung via Lock Screen > App wird für Media Button Events registriert > App managed Play State > App liefert MetaData an Remote Control
    • Media> Audio Remote > In Aktion ...
    • Media> Audio Remote > In Aktion ... audioManager. registerMediaButtonEventReceiver MyMediaButtonEventReceiver (extends BroadcastReceiver) MyRemoteControlClient (extends RemoteControlClient) audioManager. registerRemoteControlClient
    • Media> New Media Codecs > Unterstützung weiterer Media Codecs > WebP für High-Quality komprimierte Bilder > VP8 Video Streaming > HTTP Live Streaming Protocol V3 > ADTS Container für AAC Inhalte > Matroska Container für Vorbis und VP8
    • Demo(s)
    • Lars Röwekamp | CIO New Technologies @mobileLarson @_openKnowledgeANDROID 4under the hood