More Related Content Similar to Top 5 Features of Ice Cream Sandwich with Mono for Android 4.0 (20) Top 5 Features of Ice Cream Sandwich with Mono for Android 4.01. Xamarin
Seminar
9th February 2012
Copyright 2012 © Xamarin Inc. All rights reserved
2. Agenda
Top 5 Features of Ice Cream
Sandwich
Mike Bluestein
Technical Writer
Xamarin Documentation Team
mike.bluestein@xamarin.com
Xamarin
Copyright 2012 © Xamarin Inc. All rights reserved
3. Introduction
This session will survey some of the new features
available in Android 4 Ice Cream Sandwich (ICS)
Xamarin
Copyright 2012 © Xamarin Inc. All rights reserved
4. Introduction
This session will survey some of the new features
available in Android 4 Ice Cream Sandwich (ICS)
Calendar API
Xamarin
Copyright 2012 © Xamarin Inc. All rights reserved
5. Introduction
This session will survey some of the new features
available in Android 4 Ice Cream Sandwich (ICS)
Calendar API
ShareActionProvider
Xamarin
Copyright 2012 © Xamarin Inc. All rights reserved
6. Introduction
This session will survey some of the new features
available in Android 4 Ice Cream Sandwich (ICS)
Calendar API
ShareActionProvider
Action Bar Tabs
Xamarin
Copyright 2012 © Xamarin Inc. All rights reserved
7. Introduction
This session will survey some of the new features
available in Android 4 Ice Cream Sandwich (ICS)
Calendar API
ShareActionProvider
Action Bar Tabs
TextureView
Xamarin
Copyright 2012 © Xamarin Inc. All rights reserved
8. Introduction
This session will survey some of the new features
available in Android 4 Ice Cream Sandwich (ICS)
Calendar API
ShareActionProvider
Action Bar Tabs
TextureView
Android Beam
Xamarin
Copyright 2012 © Xamarin Inc. All rights reserved
12. Calendar API
• Official Calendar API
• Read-write access to calendar data
• android.permission.READ_CALENDAR
13. Calendar API
• Official Calendar API
• Read-write access to calendar data
• android.permission.READ_CALENDAR
• android.permission.WRITE_CALENDAR
18. Calendar Demo
• Listing Calendars
• Listing Calendar Events
• Adding an Event
22. ShareActionProvider
• Enables sharing action from the Action Bar
• Creates list of app that can handle the a
sharing intent
• Keeps a history of previously used apps for
easy access later
23. ShareActionProvider
• Enables sharing action from the Action Bar
• Creates list of app that can handle the a
sharing intent
• Keeps a history of previously used apps for
easy access later
• Consistent user experience for sharing data
throughout Android
30. Action Bar Tabs
• TabActivity deprecated in ICS
• Action Bar supports tabs in ICS
31. Action Bar Tabs
• TabActivity deprecated in ICS
• Action Bar supports tabs in ICS
ActionBar.NavigationMode = ActionBarNavigationMode.Tabs;
38. TextureView Example
public class TextureViewActivity : Activity, TextureView.ISurfaceTextureListener
{
Camera _camera;
TextureView _textureView;
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
_textureView = new TextureView (this);
_textureView.SurfaceTextureListener = this;
SetContentView (_textureView);
}
public void OnSurfaceTextureAvailable (Android.Graphics.SurfaceTexture surface, int width, int height)
{
_camera = Camera.Open ();
var previewSize = _camera.GetParameters ().PreviewSize;
_textureView.LayoutParameters =
new FrameLayout.LayoutParams (previewSize.Width, previewSize.Height, (int)GravityFlags.Center);
try {
_camera.SetPreviewTexture (surface);
_camera.StartPreview ();
} catch (Java.IO.IOException ex) {
Console.WriteLine (ex.Message);
}
// this is the sort of thing TextureView enables
_textureView.Rotation = 45.0f;
_textureView.Alpha = 0.5f;
}
...
}
42. Android Beam
• Allows sharing data using Near Field
Communication (NFC)
• Pushes messages when devices are close
43. Android Beam
• Allows sharing data using Near Field
Communication (NFC)
• Pushes messages when devices are close
• Activity on one device creates a message
44. Android Beam
• Allows sharing data using Near Field
Communication (NFC)
• Pushes messages when devices are close
• Activity on one device creates a message
• Specifies Activity that can push it
45. Android Beam
• Allows sharing data using Near Field
Communication (NFC)
• Pushes messages when devices are close
• Activity on one device creates a message
• Specifies Activity that can push it
• Intent invoked on second device contains
the message data
48. Android Beam Example
Create a message
protected override void OnCreate (Bundle bundle)
{
...
_nfcAdapter = NfcAdapter.GetDefaultAdapter (this);
_nfcAdapter.SetNdefPushMessageCallback (this, this);
}
public NdefMessage CreateNdefMessage (NfcEvent evt)
{
DateTime time = DateTime.Now;
var text = ("Beam me up!nn" + "Beam Time: " +
time.ToString ("HH:mm:ss"));
NdefMessage msg = new NdefMessage (
new NdefRecord[]{ CreateMimeRecord (
"application/com.example.android.beam",
Encoding.UTF8.GetBytes (text)) });
} };
return msg;
}
public NdefRecord CreateMimeRecord (String mimeType, byte [] payload)
{
byte [] mimeBytes = Encoding.UTF8.GetBytes (mimeType);
NdefRecord mimeRecord = new NdefRecord (
NdefRecord.TnfMimeMedia, mimeBytes, new byte [0], payload);
return mimeRecord;
}
49. Android Beam Example
Create a message Receive a message
protected override void OnCreate (Bundle bundle)
{
...
_nfcAdapter = NfcAdapter.GetDefaultAdapter (this);
_nfcAdapter.SetNdefPushMessageCallback (this, this);
}
public NdefMessage CreateNdefMessage (NfcEvent evt)
{
DateTime time = DateTime.Now;
var text = ("Beam me up!nn" + "Beam Time: " +
time.ToString ("HH:mm:ss"));
NdefMessage msg = new NdefMessage (
new NdefRecord[]{ CreateMimeRecord (
"application/com.example.android.beam",
Encoding.UTF8.GetBytes (text)) });
} };
return msg;
}
public NdefRecord CreateMimeRecord (String mimeType, byte [] payload)
{
byte [] mimeBytes = Encoding.UTF8.GetBytes (mimeType);
NdefRecord mimeRecord = new NdefRecord (
NdefRecord.TnfMimeMedia, mimeBytes, new byte [0], payload);
return mimeRecord;
}
50. Android Beam Example
Create a message Receive a message
protected override void OnCreate (Bundle bundle) IParcelable [] rawMsgs = Intent.GetParcelableArrayExtra (
{ NfcAdapter.ExtraNdefMessages);
...
NdefMessage msg = (NdefMessage)rawMsgs [0];
_nfcAdapter = NfcAdapter.GetDefaultAdapter (this);
_nfcAdapter.SetNdefPushMessageCallback (this, this);
}
public NdefMessage CreateNdefMessage (NfcEvent evt)
{
DateTime time = DateTime.Now;
var text = ("Beam me up!nn" + "Beam Time: " +
time.ToString ("HH:mm:ss"));
NdefMessage msg = new NdefMessage (
new NdefRecord[]{ CreateMimeRecord (
"application/com.example.android.beam",
Encoding.UTF8.GetBytes (text)) });
} };
return msg;
}
public NdefRecord CreateMimeRecord (String mimeType, byte [] payload)
{
byte [] mimeBytes = Encoding.UTF8.GetBytes (mimeType);
NdefRecord mimeRecord = new NdefRecord (
NdefRecord.TnfMimeMedia, mimeBytes, new byte [0], payload);
return mimeRecord;
}
52. References
Introduction to Ice Cream Sandwich
http://docs.xamarin.com/android/tutorials/Introduction_to_Ice_Cream_Sandwich
Xamarin
Copyright 2012 © Xamarin Inc. All rights reserved
53. Xamarin
Seminar
Please give us your feedback
http://bit.ly/xamfeedback
Follow us on Twitter
@XamarinHQ
9th February 2012
Copyright 2012 © Xamarin Inc. All rights reserved
Editor's Notes \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n