Mapped drive reconnect at sign-in “broken” on Windows 10

I have a number of LAN network drives mapped in Windows 10 to automatically reconnect at login. I found that after a recent update, the mapped drives were no longer mapped automatically but were still available after double clicking on them in Windows Explorer.

Internet searches turned up a number of different solutions ranging from changing group policy to writing cmd files to manually mount the drives.  And while writing the cmd files seemed to be the most logically solution, knowing I would need to create over fifteen of them kept me looking. I then found this post, on of all places, which turned out to be both the simplest solution and the one that worked, which was to just make the Netlogon service auto-start.

I’m not sure if an update made Netlogon Manual start or if an update made the system now need Netlogon to auto-start but in either case, I would try it first if you are also having this problem.

Posted in Windows 10 | Leave a comment

NavigationDrawer / NavigationView check menu subitems

I needed a  NavigationDrawer in an app I was building and decided to try the “new” Material Design Support Library and use a NavigationView to implement it. Using Android Studio version 2.1, I started the app by selecting the Navigation View Activity.

Choosing the Navigation View Activity creates a project with a number of default files related to the NavigationView :

  • activity_main.xml which defines the DrawerLayout and its NavigationView
  • nav_header_main.xml which defines the NavigationView header
  • activity_main_drawer.xml which defines the NavigationView menu

and produces an example NavigationView that has a parent menu with four items and a submenu with two items. The main menu is set to automatically persist the selection by using

<group android:checkableBehavior="single">

With the submenu items acting as “action” selections that do not retain their state since the CheckableBehaviour was not set for the submenu.

With my application, I have a main menu with a one static submenu defined in the xml file and then a second submenu generated dynamically in code. Even though there are two submenus, I still want only one item in the NavigationView selected and highlighted at a time. Since the CheckableBehaviour does not extend across <menu> settings, I had to manually force the the highlight.

Each item needed to have checkable set to true.  Either in the xml:


or in code:


Then after managing the new item selected in

public boolean onNavigationItemSelected(MenuItem menuItem) {
    int menuId = menuItem.getItemId();

I initially added the following which, unfortunately, did not work…


but then I tried the following which did work to highlight the selected menu item in the NavigationView:

// Highlight the selected item in the NavigationView
NavigationView navigationView = 
        (NavigationView) findViewById(;
Posted in Android App Development | Leave a comment

Multi-Language support and SpinnerPreference – Part III

In Part II, the PreferenceFragment and the PreferenceScreen were discussed along with the fact that there is a limited number of built-in widgets available for configuring the settings. The one missing that I thought would be most useful for multi-language support was a SpinnerPreference. Language support in an app can vary over time and the spinner lends itself well to a list that can change without requiring any modifications to the user interface.

A goal in creating the SpinnerPreference was to make it’s interface as similar as possible to the built-in widgets, such as the CheckBoxPreference. Because of this all the behind the scenes layout in the SpinnerPreference is done in java and not xml. In addition, the xml preference settings needed by the CheckBoxPreference will also be used:

<string-array name="language_entries">

<string-array name="language_values">

SpinnerPreference extends DialogPreference which has a number of methods that need to be overridden in the inherited class. In the constructor, the text for the positive and negative dialog buttons is set along with the retrieval of some of the parameters set in the preferences.xml file.

public SpinnerPreference(Context context, AttributeSet attrs) {
    super(context, attrs);

    this.context = context;


    int entryValuesId = 0;
    for (int i = 0; i < attrs.getAttributeCount(); i++) {
        if (attrs.getAttributeName(i).
                equalsIgnoreCase("entries")) {
            entriesId = Integer.parseInt(
        if (attrs.getAttributeName(i).
                equalsIgnoreCase("entryValues")) {
            entryValuesId = Integer.parseInt(

    if (entryValuesId != 0) {
        String[] entryValues = context.getResources().

        // Convert String Array To ArrayList for indexOf capability
        entryValuesList = Arrays.asList(entryValues);

As mentioned, instead of using setDialogLayoutResource in the constructor to specify the layout, onCreateDialogView is overrriden and the View to display in the dialog is generated there using the values context, entriesId which were set in the constructor.

protected View onCreateDialogView() {
    LinearLayout layout = new LinearLayout(context);
    layout.setLayoutParams(new LinearLayout.LayoutParams(
    layout.setPadding(10, 10, 10, 10);

    spinner = new AppCompatSpinner(context);
    spinner.setLayoutParams(new LinearLayout.LayoutParams(
    spinner.setPadding(10, 10, 10, 10);

    if (entriesId != 0) {
        ArrayAdapter<String> spinnerArrayAdapter =
          new ArrayAdapter<String>(


    return layout;

Override onBindDialogView to bind data to the content views:

protected void onBindDialogView(View view) {

    // Set default/current/selected value if set
    if (value != null) {

Override onDialogClosed which is called when the dialog is closed. If the positive button was clicked then persist the data (save in SharedPreferences by calling persistString:

protected void onDialogClosed(boolean positiveResult) {
    try {
        if (positiveResult) {
            value = spinner.getSelectedItemPosition();

            String entryValue = entryValuesList.get(value);
            if (callChangeListener(entryValue)) {
    } catch (Exception e) {

Override onSetInitialValue to set the initial value of the preference. It is called when the preference object is added to the screen. If restorePersistedValue is true, the preference value should be restored from the SharedPreferences else the preference value should be set to the defaultValue  passed and it should also be persisted (saved).

restorePersistedValue will generally be false when you’ve specified android:defaultValue that calls onGetDefaultValue (check below) and that in turn returns a value which is passed as the defaultValue to onSetInitialValue.

protected void onSetInitialValue(boolean restorePersistedValue, 
                                 Object defaultValue) {
    try {
        if (restorePersistedValue) {
            if (defaultValue == null) {
                value = entryValuesList.indexOf(
            } else {
                value = entryValuesList.indexOf(
                        getPersistedString((String) defaultValue));
        } else {
            value = entryValuesList.indexOf((String) defaultValue);
            persistString((String) defaultValue);
    } catch (Exception e) {

Override onGetDefaultValue which is called when you set android:defaultValue . Just in case the value is undefined, you can return DEFAULT_VALUE so that it gets passed to onSetInitialValue that gets saved in SharedPreferences.

protected Object onGetDefaultValue(TypedArray a, int index) {
    return a.getString(index);
Posted in Android App Development | Leave a comment

Multi-Language support and SpinnerPreference – Part II

As mentioned in Part I, calling updateConfiguration with the correct parameters for the locale provides a simple way to switch the language used in an app. Of course, the app should always start with the language last selected by the user and should provide an easy method with which to change the displayed language.

Saving state in an Android app can take many forms. For short term, such as handling orientation changes, using savedInstanceState in onCreate or a Headless Retained Fragment works very well. However these methods are not appropriate for user settings which require a persistent storage that spans the app restarting not just the activity. For this type of storage in Android there is a built-in database, SQLite, the file system, or SharedPreferences, which I ended up selecting since I was going to use a PreferenceFragment for my user settings interface.

To implement a PreferenceFragment create a SettingsActivity which extends AppCompatActivity and include the innerClass – MyPreferenceFragment which extends the PreferenceFragment and loads the xml file that defines the preferences.

public class SettingsActivity extends AppCompatActivity {

    public void onCreate(Bundle savedInstanceState) {


                new MyPreferenceFragment()).commit();
public static class MyPreferenceFragment extends PreferenceFragment{
    public void onCreate(final Bundle savedInstanceState) {

        // Define the xml file used for preferences

The activity_settings.xml file is very simple and is used as the fragment container:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android=

The preferences.xml file provides the layout for the PreferenceScreen. The built-in widgets available for the preference screen are: CheckBoxPreference, ListPreference and EditTextPreference. In part III, we’ll add a widget that’s very useful for selecting an item from a list, the SpinnerPreference.

Posted in Android App Development | Leave a comment

Multi-Language support and SpinnerPreference – Part I

When I first started Android programming, I felt the best way to learn was to try and implement various features I felt were important in my Windows programming.  So after writing a simple Android notes application, I looked into what it would take to make it multi-language. For added flexibility, I decided to make the app’s language a user setting, which could be independent of the current locale of the device.

In Android, adding support for multiple languages is pretty straight forward: just create separate strings.xml files in values directories appended with a hyphen and the ISO language code inside your applications res directory. For example in Windows:


At runtime, Android will load the correct string file based on the locale set for the device. For more information on this check out Supporting Different Languages

One thing to remember is that string literals are discouraged in Android, which brings up the issue of strings that shouldn’t be translated. To get around this, put all the strings that need to be translated in the language specific strings.xml files and then create a file in the values directory called literals.xml for strings that do not need to be translated. In literals.xml you need to tell the compiler that the strings in the file do not need to be translated which is done by the following line:

<resources xmlns:tools="" 

To set the locale of the device, the same ISO language code used to name the values directories is used to create a region specific locale that then gets passed to the updateConfiguration function:

Locale locale = new Locale("en");
config.locale = locale;
getBaseContext().getResources().updateConfiguration( config, 

// Since new language, force the activity to restart

In part II we’ll look at saving state in an Android app and preference dialogs.

Posted in Android App Development | Leave a comment

MDX Dash Death Rattle…G35 Dash Cricket

I’ve recently had a little extra free time so I decided to try and fix a couple of automotive related annoyances I’ve been experiencing. I know that there are many people out there who are perfectly happy to turn up the radio if their car makes any funny noises, I, however, am not one of those people.

The MDX started making a grumbling/rattling noise around what seemed to be the center of the dash. When I shut off the fan and put the system on re-circulation, the noise became quieter and sometimes went away. Turning the fan speed higher made the sound less noticeable but with whooshing of the air from the system, I couldn’t tell if the sound was less or just hidden. Various combinations of switching between floor vents and dash vents did not seem to effect the sound.

My guess was that some internal component or door in the dash was broken and I was just going to have to live with it because I really didn’t want to take apart the dash. But before giving up, and because I’ve had some luck doing it in the past, I decided to look on the internet to see if there may be a TSB related to this problem. While not finding any TSBs, I did come across an interesting post Rattling Center Dash (Heater A/C Air Mix Motor) by the user 12BlueX.

Following the instructions along with watching the YouTube video made the process pretty simple. I did initially misalign the door control lever which resulted in too much heat when the system turned on but this was an easy fix by reattaching the motor with the lever engaged correctly.

Emboldened by the MDX success, I turned to to G35 with the chirping dash. Usually the chirping/squeaking/high pitched rattling seemed to come from the vents on the passenger side of the dash or behind the glovebox. Other times it almost seemed to be from the bottom of the windshield.

My initial idea was that something had come loose when the cabin air filter was changed, which is behind the glovebox. However, after replacing the cabin air filter with an OEM filter made by Nissan and installing a few zip ties to make sure everything was secure, the noise remained.

My next thought was that perhaps something had fallen into a vent. In the not too distant past, the driver side door window was shattered and glass had gotten everywhere. And while driving, covering all the vents did seem to make the sound quieter so I tried compressed air and a shop vac to see if something was in the vents. Again no success.

Once again turning to the web, I tried many, many google searches for G35 dash squeaking or high-pitched rattle which led me to suggestions that it could be the mirror or to spray the dash with WD40 or to just turn up the radio and live with it. In the end, I found the post Dash Chirping by PedalKick which suggested it was the battery. I felt this to be pretty unlikely but I went to the car and shook the battery and there was the squeak. I still couldn’t see how the sound could be so loud in the cabin but as was mentioned in the article, when I removed the cowling from around the battery, I could see the large opening in the firewall for the air intake to the heating system. After putting a little grease on the battery hold-downs and making them each fairly tight, the squeak was finally gone.

Posted in 2004 Acura MDX | Leave a comment

Fun Data Obfuscation…The Archer Super Easter Egg

While I highly recommend trying to solve the Archer Easter Egg yourself, Reddit has done a good job of summarizing it and providing hints and ultimately the solution. And even though a number of the clues are hidden in plain sight during the show, they still utilize many interesting ciphers and codes to make the hunt challenging.

Perhaps my favorite cipher in the hunt was the embedding of text in an audio channel. Contestants were directed to a  youtube video from previous clues. From there the audio is extracted and stored locally and then loaded into Sonic Visualizer. To view the embedded text, select the Layer Menu and then choose “Add Spectrogram”. For this example, the text “RPH8GBIMBU1WF0RVHXIUDWYQHIDR” was embedded in the audio. This text was then used as a passphrase for a Vigenére Cipher.

The Vigenére Cipher was just one of many ciphers used such as ROT13, Base64, and hex encoded ASCII. A great website for web-based cipher tools is

All in all, the Archer Super Easter Egg Hunt is educational as well as fun. Oh, and the show is pretty good too.


Posted in Windows 7 for development | Leave a comment

uPnP blocks VPN

Recently my Windows Server 2012r2 VPN quit accepting connections. I checked the port forwarding, I checked the user logons, I checked the client.All looked fine.

I uninstalled and reinstalled the Remote Access Server Roles along with DirectAccess and VPN (RAS). And it still did not work. After the reinstall, I did have to go back into the settings and remove the modem from RRAS ports so I could still receive landline calls.

Finally, I remembered that I had uPnP turned on for XBox Live but had not had a problem in the last six months or so. But as a test, I turned off uPnP and suddenly the VPN started working. It turns out a new computer recently added to the network was the culprit.

I always believed that the manual port forwarding list would take priority over uPnP but it turns out this is not the case. And it also appears that using uPnP is not the best idea. So after setting up the XBox Live port forwarding, I now leave uPnP off.

Posted in Windows Server 2012r2 | Leave a comment

Windows Error 809 when using VPN

I’ve set up a VPN  Server on a Windows Server 2012r2 which I usually access from my iPhone or Macbook pro. Once the correct ports are forwarded it was pretty simple and always worked. I recently tried to connect from my Windows 7 machine and my Windows 10 machine both without success.

The Windows 7 error was:

809: The network connection between your computer and the VPN server could not be established because the remote server is not responding…

and the Windows 10 error was:

File Metadata optimization is already in progress.

For this test  my server was behind a NAT but the clients were not. Since neither the iOS or MacOS systems were behind a NAT, I felt that the network configuration of the server was not contributing to the error.  Nevertheless, I searched for  ‘errors’ ‘nat’ ‘vpn’ and I got a hit for at Client behind NAT devices.

I made the following registry change specified in the post for both the Windows 7 and Windows 10 client machines:

RegValue:       AssumeUDPEncapsulationContextOnSendRule
Type:               DWORD
Data Value:    2

Then rebooted each system and they both now connect to the VPN server.

Posted in Windows Server 2012r2 | Leave a comment

Clear all events manually

Many times after changing a setting to fix something in Server 2012r2, I like to have a clean slate on reboot to better see what has and hasn’t been fixed. I found the following command that when executed from a Command Prompt launched with Run as administrator does just that:

for /F “tokens=*” %1 in (‘wevtutil.exe el’) DO wevtutil.exe cl “%1”

Posted in Windows Server 2012r2 | Leave a comment