Skip navigation

Tips and Tricks

6 Posts authored by: Randolph Kaiser

By default, when the screen is rotated your Activity is killed and restarted.  See the sample code below to save the state

 

Source:  http://stackoverflow.com/questions/5123407/losing-data-when-rotate-screen

 

//Use onSaveInstanceState(Bundle) and onRestoreInstanceState

@Override
public void onSaveInstanceState(Bundle savedInstanceState) {

 
// Save UI state changes to the savedInstanceState.  
 
// This bundle will be passed to onCreate if the process is 
 
// killed and restarted.

  savedInstanceState
.putBoolean("MyBoolean", true); 
  savedInstanceState
.putDouble("myDouble", 1.9); 
  savedInstanceState
.putInt("MyInt", 1); 
  savedInstanceState
.putString("MyString", "Welcome back to Android");   
 
// etc. 
 
super.onSaveInstanceState(savedInstanceState); 
} 
//onRestoreInstanceState 
   
@Override 
public void onRestoreInstanceState(Bundle savedInstanceState) { 
 
super.onRestoreInstanceState(savedInstanceState); 
 
// Restore UI state from the savedInstanceState. 
 
// This bundle has also been passed to onCreate. 
 
boolean myBoolean = savedInstanceState.getBoolean("MyBoolean"); 
 
double myDouble = savedInstanceState.getDouble("myDouble"); 
 
int myInt = savedInstanceState.getInt("MyInt"); 
 
String myString = savedInstanceState.getString("MyString"); 
}

It is important to note that when pairing with BSP44 that you must enter PIN number quickly otherwise it will not pair. 

 

WIth BSP44 and the RS507 with firmware PAAACS00-005-R02D0 the procedure is as follows:

 

1.  Load the follwing as a reg file into the Application Folder

; BT Scanner settings for 41.400 / 44.00

[HKEY_LOCAL_MACHINE\Drivers\BuiltIn\BarcodeReaderBT]
"Flags"=dword:00000000

[HKEY_LOCAL_MACHINE\Drivers\BuiltIn\BarcodeReaderBT\Settings]
"PortName"="\$device\COM7"

2.  Click on the .reg file -> click on it to merge it.

3.  Warm boot the MC65

4.  Clean boot the RS507 - procedure -hold down the button on the back right and place battery in it until it beeps several times.

5.  To avoid having to enter a Pin number please scan Disable Bluetooth Authentication.

 

Bluetooth Authentication.png

6.  On the MC65 tap on the MotoBtui and turn on Bluetooth. 

7.  Click on Pairing barcode icon -  This must be down after the RS507 is on

8.  Scan the pairing barcode.

 

If you want to pair it with having to enter a PIN then follow

1.  Load the follwing as a reg file into the Application Folder

; BT Scanner settings for 41.400 / 44.00

[HKEY_LOCAL_MACHINE\Drivers\BuiltIn\BarcodeReaderBT]
"Flags"=dword:00000000

[HKEY_LOCAL_MACHINE\Drivers\BuiltIn\BarcodeReaderBT\Settings]
"PortName"="\$device\COM7"

2.  Click on the .reg file -> click on it to merge it.

3.  Warm boot the MC65

4.  Clean boot the RS507 - procedure -hold down the button on the back right and place battery in it until it beeps several times.

6.  On the MC65 tap on the MotoBtui and turn on Bluetooth. 

7.  Click on Pairing barcode icon -  This must be down after the RS507 is on

8.  Scan the pairing barcode

9.  Enter the PIN (12345) very quickly prior to the light flashing on the RS507 going off

Setting the Date and Time on an SB1.  There are many ways to set the date and time
on an SB1.  One way is to set it with the Fusion settings.  When you create a
Fusion Profile in MSP the Fusion Option is set by default.  This will set the date and time based off the
Wireless infrastructure.  If you are using Motorola Solutions Infrastructure it will set the date and time.

 

On the device to set the date and time manually the user will need to set it through the GUI in advanced  settings under Set Date and Time.

Over the last several years most partners have had multiple instances of their application running on the device which has
caused some issues for them.  It has been my experience that the partners need to check for this in their apps.  There are several ways to check for this
depending on what programming language is used.  Here are some links and snippets of code:

 

int _tmain(int argc, _TCHAR* argv[])

  {

  
// CREATE A SINGLE INSTANCE MUTEX

   
HANDLE hMutex = CreateMutex(NULL, FALSE, L"ApplicationNameSingleInstanceMutex");

       if (hMutex != NULL)

       {       
if (GetLastError() == ERROR_ALREADY_EXISTS)

          
{

                 
// MUTEX ALREADY EXISTS, EXIT APPLICATION

              
CloseHandle(hMutex);

               
return -2;

         
}

       }

       else

       {

         
// ERROR CREATING MUTEX

         
return -1;

       }

      
// NORMAL APPLICATION PROCESSING HERE

        // CLOSE HANDLE TO MUTEX

   CloseHandle(hMutex);   

       return 0;

  }

 

  Also please check this post out :

  http://social.msdn.microsoft.com/Forums/en-us/netfxcompact/thread/18b8ec06-89e2-4318-8eb9-d26bd42ac1b2

     I have included another link here: 

  
http://www.nesser.org/blog/archives/56
and a copy of his code:  The below was needed because users were not patient : Most users are not.  Here is some sample code:  This is for C#

 

 

 

using System;

  using System.Windows.Forms;

  using System.Runtime.InteropServices;

  namespace SomeNameSpace

 

{

  static class SingleInstance

  {

  [MTAThread]

  static void Main()

  {

  // Check if we have a duplicate
instance of the program running

  if (
IsInstanceRunning() )

 

{

  // Perhaps log the fact a duplicate
program was shut down

  return;

  }

  /*

  * Continue with your normal program here

  */

  try

  {

  Application.Run( YourFormClass );

  }

  catch ( Exception
e )

  {

  // Log an exception that caused the
application to close here

  MessageBox.Show( "See log file
for details.\r\nClosing this application.", "Fatal Application
Error"
);

 

}

  }

  #region OpenNETCF native interface
to mutex generation (version 1.4 of the SDF)

  public const Int32
NATIVE_ERROR_ALREADY_EXISTS = 183;

 

#region P/Invoke Commands for
Mutexes

  [DllImport(
"coredll.dll", EntryPoint="CreateMutex", SetLastError=true
)]

  public static extern IntPtr
CreateMutex(

  IntPtr lpMutexAttributes,

 

bool InitialOwner,

 

string MutexName
);

  [DllImport(
"coredll.dll", EntryPoint="ReleaseMutex", SetLastError=true
)]

 

public static extern bool ReleaseMutex(
IntPtr hMutex );

 

 

#endregion

 

 

public static bool IsInstanceRunning()

 

 

{

 

 

IntPtr hMutex = CreateMutex(
IntPtr.Zero, true, "ApplicationName"
);

 

 

if ( hMutex == IntPtr.Zero )

 

 

throw new ApplicationException(
"Failure creating mutex: "

  +
Marshal.GetLastWin32Error().ToString( "X"
) );

 

if (
Marshal.GetLastWin32Error() == NATIVE_ERROR_ALREADY_EXISTS )

  return true;

  else

  return false;

  }

  #endregion

  }  

}

In MSP under settings ->  Click on Create and in the Setting Type drop down select FILE.SETTINGS.XML and then select the registry file and place it in the Application directory as shown below.
After creating the setting The user will need to create a staging barcode with just the setting selected.

 

msp1.png

 

msp1.png

 

Click on the Staging – Barcode in MSP and you will get the Barcode Below. The barcode below will set the MTU to 1300 on the SB1. It is a standalone barcode not requiring a backend.
The user must cold boot the device for the setting to take effect.

 

The below barcode wil set the MTU setting on an SB1 to 1300 as long as the user cold boots the device.

msp1.png

The registry key is below:

     [HKEY_LOCAL_MACHINE\Comm\NPME\XWING10_1\Parms\TcpIp]

       ; Set MTU to 1300

          "MTU"=dword:514

A registry file will need to be created and placed in the User drive or the Application Folder to configure the setting

Filter Blog

By date:
By tag: