MyAdviceWriter ...

Starting Friday March 24 I’m working with Microsoft and the community of MVP’s to resurrect a type of event format we used to run for MSDN, the half day – Explore the Possible – see it in action – event. I’d love to invite you to join me on the tour, stop by and say hi. We will explore the move towards productivity and effectiveness of development and deployment tools and technologies.

Since Visual Studio launched 20 years ago it has evolved to become a favorite IDE of the casual to professional developer. With the launch of Visual Studio 2017 Microsoft has stepped up their game with improvements to make it easier to work with Cloud, Mobile and Web, as well as a number of productivity improvements. Join us as we explore the possible with the latest tools and technologies with Visual Studio, Xamarin and the Mobile Center, and DevOps with Team Services. The day starts at 8:30 and ends with a hackfest/install pizza party.

  • 8:30 – Hello Visual Studio
  • 9:45 – Exploring Mobile Stack
  • 11:00 – DevOps, .NET Core, Docker and more
  • 12:00 – Pizza & Hackfest

The list of cities and dates include:

Hope to see you there!

-mike

Watching the live stream of the Visual Studio 2017 launch and 20 year anniversary party…thought I’d capture some of the notes of what’s going on and share the fun.

Visual Studio 2017 release

Developer Productivity - Kasey Uhlenhuth

  • Live Unit Tests
  • Exception helper
  • Find all references
  • New intellitrace tray of options
  • Ctrl+T for goto All
  • Code suggestions
  • Code Config file - map code styles and suggestions for environment
  • Support for tuples on methods
  • Improved refactoring
  • Indent guide visibility to method code is in even if not visible

.NET Core - Beth Massi

  • .net Tools for Core 1.0 in production
  • Migrate/Upgrade to new tools easy
  • Simplified csproj format which is human readable
  • References grouped by type…i.e. nuget refs, project refs, etc.
  • Application Insights
    • New add-in experience
    • Search and graph analytics in VS

Containers Docker - Scott Hanselman

  • Add docker support in VS right click on project
  • Run in docker if selected startup project
  • Debug, edit and volume mapping realtime from vs to docker
  • Publish to Linux docker or windows
  • Automatically references other docker containers dependent on
  • Debug across containers
  • Check out Ref application http://aka.ms/MicroservicesArchitecture

Xamarin : James & Miguel

  • Tizen new OS from Samsung for IoT devices…built on Xamarin Forms
  • Visual Studio for Mac Preview 4
  • New App templates
    • Mobile App added with best practices if checkbox Azure
    • Code for clients
  • Forms Previewer
    • Works if you have JDK 1.8+ on x64 installed (settings?)
  • Improved intellisense
  • Native animations in XAML
  • Forms inspector, when connected tp android emulator
    • Layers
    • Live edit of XAML

VS Mobile Center - Keith

  • http://mobile.azure.com
  • Xamarin Test Cloud
  • Add app…pick type
  • Add nuget & register app
  • Distribute sets up a team of testers/user community for builds
  • Build service
    • Pick sln
    • Provisioning profile
    • Certificate for signed builds
    • Trigger
  • Test service …
    • run automated UI tests
    • See devices tested on
  • Crash reporting
    • Usage & crash info
    • Stack dumps grouped by count
  • Analytics
    • Custom events

DevOps - Brian Harry & Donovan Brown

  • Continuous delivery
  • "Shift Right" = delivery improvements, production is part of the plan
  • TFS 2017.1 for on Premise installs
  • http://aka.ms/tfsimportdata
  • Donovan demo - any project, any platform
    • Create project
    • Import Git repo
    • View code
    • Setup build from templates or by scratch
      • Sources - where is repo? In TS or external?
      • Test settings
      • Code Coverage
      • Build agents - windows or linux
      • Search for build task
      • Marketplace for build tasks
      • Create your own extension
      • Variables
      • Create work items on failure
      • Track history/changes to build definitions
    • Release definitions
      • Infrastructure as code
      • Approvers
    • Dashboards
  • Data Migration - Partner with Red Gate
    • In VS RedGate ReadyRoll has tools by default
    • SQL Obj explorer, make changes and save
    • Tell ReadyRoll to refresh with changes, generate migration scripts
      • Add update statements for populating default values on existing data after modification
    • Add database scripts and changes that will happen on the database
    • Add the ReadyRoll task to deploy the database task
  • RedGate included in VS 2017 Enterprise
  • Pluralsight 1yr
  • DevOps Enterprise Accelerator offer

I’ve been working on a project that integrates Xamarin with Azure Mobile Apps and uses HockeyApp to distribute the code to test devices. I wanted to add the feature in HockeyApp to allow users to be able to send feedback (including a screenshot) from within the app. On searching for an answer I found a number of good leads but nothing that connected them all so this post is intended to go thru what you need to do to add this feature to your app.

We start with an app that is created from the standard Xamarin Forms template in Visual Studio for cross-platform apps (this assumes you have Visual Studio 2015.3 with the Xamarin tools installed otherwise it will prompt you to add them).

image

The solution will look like this. Note I had to do a little work to use the Shared version of Xamarin forms with XAML in that I replaced the default App.cs file it includes with XAML versions of that and the MainPage.xaml. You can see the completed demo sample on GitHub here

image

To add HockeyApp’s feedback feature to our solution go to https://www.hockeyapp.net/ and sign up to create a new app. After an app has been created you can get the HockeyApp ID and use it in the MainActivity.cs code for the OnCreate() method when the application registers with HockeyApp. The process is fairly straight forward:

  1. Create a new app on HockeyApp (https://support.hockeyapp.net/kb/app-management-2/how-to-create-a-new-app)
  2. Add the HockeyApp component from Xamarin (https://components.xamarin.com/view/hockeyappandroid)
    SNAGHTML4b9e527[4]
  3. In the MainActivity.cs file of the Android project add a function to register HockeyApp with the AppID you created. We will call it from the OnCreate(). 
  4. private void InitializeHockeyApp()
    {
        CrashManager.Register(this, HOCKEYAPP_APPID, new MyCrashManagerListener());
       
        UpdateManager.Register(this, HOCKEYAPP_APPID);
        FeedbackManager.Register(this, HOCKEYAPP_APPID);
        Tracking.StartUsage(this);
       
    }

  5. Add a method to handle the feedback calls in the MainActivity class. In this implementation I’m also capturing a screenshot that can be added to the feedback process if the user chooses.
  6. public void HandleFeedback()
    {
        FeedbackManager.SetActivityForScreenshot(MainActivity.current);
        FeedbackManager.TakeScreenshot(MainActivity.current);

        FeedbackManager.ShowFeedbackActivity(MainActivity.current);
    }

  7. Implement an ISensorEventListener class to handle shake activity. Note that you need to implement both the Java.Lang.Object interface as well as the ISensorEventListener. I added an overloaded constructor to allow me to pass a reference to the MainActivity instance (parent) that uses this to handle sensor activity. We will also handle the 

  8. // --- Implement ISensorEventListener
    public class MyShakeHandler : Java.Lang.Object, ISensorEventListener
    {
        // --- Reference to parent activity
        private MainActivity parent;

        // Handle Shake from - http://stackoverflow.com/questions/23120186/can-xamarin-handle-shake-accelerometer-on-android
        bool hasUpdated = false;

        DateTime lastUpdate;
        float last_x = 0.0f;
        float last_y = 0.0f;
        float last_z = 0.0f;

        const int ShakeDetectionTimeLapse = 250;
        const double ShakeThreshold = 800;

        // --- In constructor set parent
        public MyShakeHandler(Activity context) : base()
        {
            parent = (MainActivity)context;
        }

        public void OnAccuracyChanged(Android.Hardware.Sensor sensor, Android.Hardware.SensorStatus accuracy)
        {
        }

        public void OnSensorChanged(Android.Hardware.SensorEvent e)
        {
            if (e.Sensor.Type == Android.Hardware.SensorType.Accelerometer)
            {
                float x = e.Values[0];
                float y = e.Values[1];
                float z = e.Values[2];

                DateTime curTime = System.DateTime.Now;
                if (hasUpdated == false)
                {
                    hasUpdated = true;
                    lastUpdate = curTime;
                    last_x = x;
                    last_y = y;
                    last_z = z;
                }
                else
                {
                    if ((curTime - lastUpdate).TotalMilliseconds > ShakeDetectionTimeLapse)
                    {
                        float diffTime = (float)(curTime - lastUpdate).TotalMilliseconds;
                        lastUpdate = curTime;
                        float total = x + y + z - last_x - last_y - last_z;
                        float speed = Math.Abs(total) / diffTime * 10000;

                        if (speed > ShakeThreshold)
                        {
                            // --- Call parent's Feedback handler
                            parent.HandleFeedback();
                        }

                        last_x = x;
                        last_y = y;
                        last_z = z;
                    }
                }
            }
        }
    }

  9. In the MainActivity.cs OnCreate() function add code to add an accelerometer sensor recognition. Note that you also have to add usings for Android.Hardware and for HockeyApp.Android. The code for OnCreate() will look like this:
  10.         // --- Add Globals
            public static string HOCKEYAPP_APPID = "<HOCKEYAPP ID>";
            public static Android.App.Activity current;

            protected override void OnCreate (Bundle bundle)
            {
                base.OnCreate (bundle);

                // --- Register this as a listener with the underlying service.
                var sensorManager = GetSystemService(SensorService) as Android.Hardware.SensorManager;
                var sensor = sensorManager.GetDefaultSensor(Android.Hardware.SensorType.Accelerometer);

                current = this;
                sensorManager.RegisterListener(new MyShakeHandler(current), sensor, Android.Hardware.SensorDelay.Normal);
                InitializeHockeyApp();

     

                global::Xamarin.Forms.Forms.Init (this, bundle);
                LoadApplication(new App());
            }

  11. In the AndroidManifest.xml add permissions to the sensors
  12. <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android">
      <uses-sdk android:minSdkVersion="15" />
      <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
      <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
      <uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
      <uses-permission android:name="android.permission.INTERNET" />
      <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
      <uses-feature android:name="android.hardware.sensor.accelerometer" android:required="true" />
      <application android:label="xForms-FeedbackDemo"></application>
    </manifest>

  13. In my scenario I also wanted a button on an about page that can be used to trigger the feedback logic from XAML. To make it work with a Shared code project in Xamarin Forms, I defined a DROID compilation definition so I can conditionally work with Android specific code
    image
  14. In the XAML page you want to add a feedback button connect to the MainActivity’s logic. 
  15. using System;
    using Xamarin.Forms;

    #if DROID
    using HockeyApp.Android;
    using XamFormsFeedbackDemo.Droid;
    #endif

    namespace XamFormsFeedbackDemo
    {
        public partial class MainPage : ContentPage
        {
            public MainPage ()
            {
                InitializeComponent ();
            }
            public void btnFeedback(object sender, EventArgs e)
            {
    #if DROID
                FeedbackManager.SetActivityForScreenshot(MainActivity.current);
                FeedbackManager.TakeScreenshot(MainActivity.current);

                FeedbackManager.ShowFeedbackActivity(MainActivity.current);
    #endif
            }
        }
    }

You can download the code from GitHub here.

Happy Coding!

Building code is always fun, especially when you get to work with new technologies and cool tools that make our lives as developers easier. One of those concepts that is driving a lot of organizations is that of DevOps, which we will define here as an approach for automating and  connecting work done with released software. In this article I’d like to show how to connect some of the tools available from Microsoft to work with mobile applications. This will include Xamarin, Team Services, HockeyApp and Azure Mobile Apps.

The process flow

  1. Create a Team Project – myXamarinDemo
  2. In Visual Studio create a Xamarin Forms with XAML and PCL project
  3. Add the solution to source control (use GIt and navigate to select the team project you created)
  4. Commit & Sync
  5. In Team Services add a build definition (Xamarin.Android template)
  6. Remove the steps that activate and deactivate the license, then queue a build
  7. In VS droid project add HockeyApp.droid component and code to register app

 

 

DevOps is

It's great to be back in Kansas City for another Dev Camp. I wanted to share some info from my talks, including the deck (below). Enjoy!

It's great to be back in Kansas City for another Dev Camp. I wanted to share some info from my talks, including the deck (below). Enjoy!

Wow, what a great turnout this last week at Open Source North in Minneapolis. Kudos to Jeff Urban and team for putting on another great show! Here are some links to more information from the talk...

As promised here’s the slide deck from last week. I’m working with Speaker Deck to make them available and still figuring out how to get make it work. Enjoy!

Just finished with the Global Azure Boot Camp last week, wanted to post links to the deck and to the downloads.

imageSince Windows 8 came out its been hard to find some tools that used to work so well with previous versions of Windows. One such tool is Live Writer, which was part of Windows Essentials. I came across this a couple weeks ago and wanted to share, I’ve been using it to work with my blogs and you can get it from http://openlivewriter.org/. I’m starting a new blog and will be updating BenkoTIPS to have an aggregated feed of items from historical blogs I’ve worked on. Should be a fun project.

Enjoy!

This morning, club President Vince Bullinger, Vice President of Membership Mike Benkovich (and his daughter) and Treasurer Brette Esterbrooks visited the Crest Toastmasters club in Eden Prairie. It is an advanced club filled with past district leaders that focus on improving Toastmasters clubs in the area.

This was a great opportunity to not only get the Elusive Gilded Gavel (EGG), but also to connect with advanced Toastmasters and see how they run a meeting. We promoted our upcoming TechMasters After Dark event as well, and passed out a handful of copies of our flyer for the event.

Now, other clubs will be visiting our club to not only see what we do well, but see if they can offer suggestions on how to improve. Also, we may snag members or dual members of other clubs if they like the way we run things or if they are technology-focused in their careers (as we are). Plus, we may end up in the district newsletter and on the EGG website.

Visiting other clubs is always a great idea, but advanced clubs like this one are a special treat.

egg

Load more...