Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin

777 views

Published on

In this webinar deck Tom Opgenorth dives into what’s new in Android 8 Oreo and shows how to add the latest features – like Picture-in-picture, notification channels, downloadable fonts, and more – to your apps, 100% in .NET and Visual Studio. Whether you’re building new or updating existing Xamarin.Android apps, you’ll get the step-by-step demos, code samples, and expert tips you need to start shipping Android 8 Oreo-ready apps to your users immediately.

Watch webinar at https://youtu.be/qEW6AyUdnKw

Published in: Software
  • How To Pick Out The Best Battery For a Solar Panel System, Battery Bank, or Off-Grid System ■■■ http://t.cn/AiFAGBwT
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin

  1. 1. dependencies { ... compile “com.android.support:support-emoji:27.0.0” }
  2. 2. developer.android.com
  3. 3. developer.android.com
  4. 4. developer.android.com
  5. 5. developer.android.com
  6. 6. <?xml version="1.0" encoding="utf-8"?> <adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> <background android:drawable="@color/ic_launcher_background"/> <foreground android:drawable="@mipmap/ic_launcher_foreground"/> </adaptive-icon>
  7. 7.   developer.android.com
  8. 8. developer.android.com
  9. 9. public const string PRIMARY_CHANNEL_ID = "default"; var chan1 = new NotificationChannel( PRIMARY_CHANNEL_ID, channelName, NotificationImportance.Default); var channelName = GetString(Resource.String.noti_channel_default); chan1.LightColor = Color.Green; chan1.LockscreenVisibility = NotificationVisibility.Private; manager.CreateNotificationChannel(chan1); var manager = (NotificationManager)GetSystemService(NotificationService);
  10. 10. var notificationBuilder= new Notification.Builder(ApplicationContext, PRIMARY_CHANNEL_ID) .SetContentTitle(title) .SetContentText(body) .SetSmallIcon(smallIcon) .SetAutoCancel(true); var manager = (NotificationManager)GetSystemService(NotificationService); manager.Notify(notificationId, notificationBuilder.Build(); public const string PRIMARY_CHANNEL_ID = "default";
  11. 11. developer.android.com/guide/components/broadcast-exceptions.html
  12. 12. developer.android.com
  13. 13. [Activity(Label = "PictureInPicture", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.SmallestScreenSize | ConfigChanges.ScreenLayout | ConfigChanges.Orientation, SupportsPictureInPicture = true)] public class MainActivity : AppCompatActivity { }
  14. 14. bool EnterPictureInPictureMode(PictureInPictureParams @params); public class Builder { public Builder(); public PictureInPictureParams Build(); public PictureInPictureParams.Builder SetActions(IList<RemoteAction> actions); public PictureInPictureParams.Builder SetAspectRatio(Rational aspectRatio); public PictureInPictureParams.Builder SetSourceRectHint (Rect launchBounds); }
  15. 15. public override void OnPictureInPictureModeChanged(bool isInPictureInPictureMode, Configuration newConfig) { base.OnPictureInPictureModeChanged(isInPictureInPictureMode, newConfig); if (isInPictureInPictureMode) { // Hide the controls in picture-in-picture mode. } else { // Restore fullscreen UI. } }
  16. 16. protected override void OnUserLeaveHint() { if (iWantToBeInPipMode) { EnterPictureInPictureMode(BuildParametersForPiP()); } }
  17. 17. TextView regular TextVie w auto- sizing
  18. 18. <?xml version="1.0" encoding="utf-8"?> <TextView android:layout_width="match_parent" android:layout_height="200dp" android:autoSizeTextType="uniform" android:autoSizeMinTextSize="12sp" android:autoSizeMaxTextSize="100sp" android:autoSizeStepGranularity="2sp" />
  19. 19. <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent“ android:orientation="vertical" > <TextView android:id="@+id/text_view“ android:layout_width="match_parent" android:layout_height="200dp" android:text="Auto Size Text." app:autoSizeTextType="uniform" /> </LinearLayout>
  20. 20. developer.android.com
  21. 21. <EditText android:id="@+id/passwordField" android:layout_width="@dimen/text_field_width" android:layout_height="wrap_content" android:autofillHints="password" android:inputType="textPassword“ />
  22. 22. <TextView android:text="The quick brown fox jumped over the lazy dog.“ android:textAppearance="?android:attr/textAppearanceLarge" android:layout_width="match_parent" android:layout_height="wrap_content" />
  23. 23. <?xml version="1.0" encoding="utf-8"?> <font-family xmlns:android="http://schemas.android.com/apk/res/android"> <font android:fontStyle="normal" android:fontWeight="400" android:font="@font/lobster_regular"/> <font android:fontStyle="italic“ android:fontWeight="400“ android:font="@font/lobster_italic" /> </font-family>

  24. 24. Fonts Contract Font Provider Font Cache
  25. 25. <?xml version="1.0" encoding="utf-8"?> <font-family xmlns:android=“http://schemas.android.com/apk/res/android” android:fontProviderAuthority=“com.example.fontprovider.authority” android:fontProviderPackage="com.example.fontprovider" android:fontProviderQuery="example font" android:fontProviderCerts="@array/certs"> </font-family>
  26. 26. <?xml version="1.0" encoding="utf-8"?> <resources> <array name="preloaded_fonts"> <item>@font/font1</item> <item>@font/font2</item> </array> </resources>
  27. 27. <meta-data android:name="preloaded_fonts“ android:resource="@array/preloaded_fonts"/> [Application] [MetaData("preloaded_fonts", Resource="@array/preloaded_fonts")] public class EmojiCompatApplication : Application { // Code omitted for clarity }
  28. 28. FontRequest request = new FontRequest( "com.google.android.gms.fonts", "com.google.android.gms", query, Resource.Array.com_google_android_gms_fonts_certs);
  29. 29. class FontRequestCallbackImpl : FontsContractCompat.FontRequestCallback { public override void OnTypefaceRetrieved(Android.Graphics.Typeface typeface) { // Font downloaded - do something with the typeface } public override void OnTypefaceRequestFailed(int reason) { // Download failed - react to the failure } }
  30. 30. HandlerThread handlerThread = new HandlerThread("fonts"); handlerThread.Start(); FontsContractCompat.RequestFont(this, request, callback, handlerThread);
  31. 31. developer.android.com
  32. 32. // Use downloadable fonts for EmojiCompat var fontRequest = new FontRequest("com.google.android.gms.fonts", "com.google.android.gms", "Noto Color Emoji Compat", Resource.Array.com_google_android_gms_fonts_certs); EmojiCompat.Config config = new FontRequestEmojiCompatConfig(this, fontRequest) .SetReplaceAll(true) .RegisterInitCallback(new InitCallbackImpl()); EmojiCompat.Init(config); // OR, if using the bundled EmojiCompat package: EmojiCompat.Config config = new BundledEmojiCompatConfig(this); EmojiCompat.Init(config);
  33. 33. <android.support.text.emoji.widget.EmojiTextView android:layout_width="wrap_content" android:layout_height="wrap_content"/> <android.support.text.emoji.widget.EmojiAppCompatTextView android:layout_width="wrap_content" android:layout_height="wrap_content"/>
  34. 34. <android.support.text.emoji.widget.EmojiEditText android:layout_width="wrap_content" android:layout_height="wrap_content"/> <android.support.text.emoji.widget.EmojiAppCompatEditText android:layout_width="wrap_content" android:layout_height="wrap_content"/>
  35. 35. <android.support.text.emoji.widget.EmojiButton android:layout_width="wrap_content" android:layout_height="wrap_content"/> <android.support.text.emoji.widget.EmojiAppCompatButton android:layout_width="wrap_content" android:layout_height="wrap_content"/>
  36. 36. github.com/xamarin/monodroid-samples/tree/master/android-o www.youtube.com/user/androiddevelopers developer.android.com/about/versions/oreo/index.html xamarin.com/download
  37. 37. Tom Opgenorth Senior Content Developer, Microsoft

×