Showing posts with label mobile. Show all posts
Showing posts with label mobile. Show all posts

Tuesday, April 6, 2010

Monday, March 30, 2009

Useful tool for the presentation of your mobile application

"Real-Time Remote Control" and "Presentation Tools" will be very useful.

Pocket Controller Pro

Sunday, March 1, 2009

How to capture screenshots of mobile device or emulator

Here is a procedure to follow to take a screenshot.

1. Open "Microsoft Visual Studio 2005 -> Visual Studio Remote Tools -> Remote Zoom In".

2. Select one on a "Select a Windows CE Device" dialog, which is the thing you want to connect. Make sure a device connected to your computer.

3. You will see the screenshot. If you want to take another screenshot, click "Target -> Refresh" on the menu of the Remote Zoom In, or press F5 key.

4. Now, you can save the screenshot as an image (BMP). Select "File -> Save As".

Thursday, February 12, 2009

How to connect a server from mobile client in C#

I need to know this.

Get "unique device ID" of a mobile device

I searched Internet a lot to find how to get "unique device id" for mobile devices, which is not dependent on any application data.

I am developing on Windows Mobile 6 with HTC phone.

There are severay ways to do it.

1) Use GetDeviceUniqueID(): GetDeviceUniqueID() requires at least 8 bytes of data to generate a hash. Furthermore, you should not expect GetDeviceUniqueID() to return the UUID string as HAL_GET_DEVICEID does. It will return application-specific hash that is unique for this particular device. You should treat it as a sequence of bytes.

2) Use HAL_GET_DEVICEID: This does not work on Smartphone unless your code is signed with a privleged certificate.

3) Get IMEI(International Mobile Equipment Identity) number: The IMEI number is a unique 15-digit code used to identify an individual GSM mobile phone in a GSM network. The IMEI number can be displayed on most phones by dialing the code *#06#. Every phone has a unique IMEI number, which is usually printed under the battery on the phone. The IMEI number is used in many mobile applications since the unique number makes it possible to lock software to a particular phone. This effectively prevents unauthorized copying of an application.
--> Use Tapi dll
--> Make your code (See, References (2))
: References
1) Getting the IMEI number: a UIQ 3 code example

2) IMEI in C#





using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;

// Reference: http://groups.google.com/group/microsoft.public.dotnet.framework.compactframework/browse_thread/thread/280299812d7b171c
public class clsDeviceInfo
{
private string _manufacture;
private string _model;
private string _revision;
private string _serialNumber; // IMEI
private string _subscriberID; // IMSI

public string Manufacture
{
get { return _manufacture; }
}

public string Model
{
get { return _model; }
}

public string Revision
{
get { return _revision; }
}

public string SerialNumber
{
get { return _serialNumber; }
}

public string SubscriberID
{
get { return _subscriberID; }
}

public clsDeviceInfo()
{
GetDeviceInfo();
}

private void GetDeviceInfo()
{
IntPtr hLine;
int dwNumDev;
int num1 = 0x20000;

LINEINITIALIZEEXPARAMS lineInitializeParams = new LINEINITIALIZEEXPARAMS();
lineInitializeParams.dwTotalSize = (uint)Marshal.SizeOf(lineInitializeParams);
lineInitializeParams.dwNeededSize = lineInitializeParams.dwTotalSize;
lineInitializeParams.dwUsedSize = lineInitializeParams.dwUsedSize;
lineInitializeParams.dwOptions = 2;
lineInitializeParams.hEvent = IntPtr.Zero;
lineInitializeParams.hCompletionPort = IntPtr.Zero;

// lineInitializeEx
int result = NativeTapi.lineInitializeEx(out hLine, IntPtr.Zero, IntPtr.Zero, null, out dwNumDev, ref num1, ref lineInitializeParams);
if (result != 0)
{
return;
}

// lineNegotiateAPIVerison
int version;
int dwAPIVersionLow = 0x10004;
int dwAPIVersionHigh = 0x20000;
LINEEXTENSIONID lineExtensionID;
result = NativeTapi.lineNegotiateAPIVersion(hLine, 0, dwAPIVersionLow, dwAPIVersionHigh, out version, out lineExtensionID);
if (result != 0)
{
return;
}

// lineOpen
IntPtr hLine2 = IntPtr.Zero;
result = NativeTapi.lineOpen(hLine, 0, out hLine2, version, 0, IntPtr.Zero, 0x00000002, 0x00000004, IntPtr.Zero);
if (result != 0)
{
return;
}

// lineGetGeneralInfo
int structSize = Marshal.SizeOf(new LINEGENERALINFO());
byte[] bytes = new byte[structSize];
byte[] tmpBytes = BitConverter.GetBytes(structSize);

for (int index = 0; index < tmpBytes.Length; index++)
{
bytes[index] = tmpBytes[index];
}

// make initial query to retrieve necessary size
result = NativeTapi.lineGetGeneralInfo(hLine2, bytes);

// get the needed size
int neededSize = BitConverter.ToInt32(bytes, 4);

// resize the array
bytes = new byte[neededSize];

// write out the new allocated size to the byte stream
tmpBytes = BitConverter.GetBytes(neededSize);
for (int index = 0; index < tmpBytes.Length; index++)
{
bytes[index] = tmpBytes[index];
}

// fetch the information with properly size buffer
result = NativeTapi.lineGetGeneralInfo(hLine2, bytes);
if (result != 0)
{
//LogManager.GetLogger("DeviceInfo").Error(Marshal.GetLastWin32Error().ToString());
return;
}

int size;
int offset;

size = BitConverter.ToInt32(bytes, 12);
offset = BitConverter.ToInt32(bytes, 16);

// manufacture
if (size > 0 && offset > 0)
{
_manufacture = Encoding.Unicode.GetString(bytes, offset, size);
_manufacture = _manufacture.Substring(0, _manufacture.IndexOf('\0'));
}

size = BitConverter.ToInt32(bytes, 20);
offset = BitConverter.ToInt32(bytes, 24);

// model
if (size > 0 && offset > 0)
{
_model = Encoding.Unicode.GetString(bytes, offset, size);
_model = _model.Substring(0, _model.IndexOf('\0'));
}

size = BitConverter.ToInt32(bytes, 28);
offset = BitConverter.ToInt32(bytes, 32);

// revision
if (size > 0 && offset > 0)
{
_revision = Encoding.Unicode.GetString(bytes, offset, size);
_revision = _revision.Substring(0, _revision.IndexOf('\0'));
}

size = BitConverter.ToInt32(bytes, 36);
offset = BitConverter.ToInt32(bytes, 40);

// serial number (IMEI)
if (size > 0 && offset > 0)
{
_serialNumber = Encoding.Unicode.GetString(bytes, offset, size);
_serialNumber = _serialNumber.Substring(0, _serialNumber.IndexOf('\0'));
}

size = BitConverter.ToInt32(bytes, 44);
offset = BitConverter.ToInt32(bytes, 48);

// subscriber id (IMSI)
if (size > 0 && offset > 0)
{
_subscriberID = Encoding.Unicode.GetString(bytes, offset, size);
_subscriberID = _subscriberID.Substring(0, _subscriberID.IndexOf('\0'));
}

// lineClose for hLine2
NativeTapi.lineClose(hLine2);

// lineShutdown for hLine
NativeTapi.lineShutdown(hLine);
}

[StructLayout(LayoutKind.Sequential)]
private struct LINEEXTENSIONID
{
public IntPtr dwExtensionID0;
public IntPtr dwExtensionID1;
public IntPtr dwExtensionID2;
public IntPtr dwExtensionID3;
}

[StructLayout(LayoutKind.Sequential)]
private struct LINEINITIALIZEEXPARAMS
{
public uint dwTotalSize;
public uint dwNeededSize;
public uint dwUsedSize;
public uint dwOptions;
public System.IntPtr hEvent;
public System.IntPtr hCompletionPort;
public uint dwCompletionKey;
}

[StructLayout(LayoutKind.Sequential)]
private struct LINEGENERALINFO
{
public int dwTotalSize;
public int dwNeededSize;
public int dwUsedSize;
public int dwManufacturerSize;
public int dwManufacturerOffset;
public int dwModelSize;
public int dwModelOffset;
public int dwRevisionSize;
public int dwRevisionOffset;
public int dwSerialNumberSize;
public int dwSerialNumberOffset;
public int dwSubscriberNumberSize;
public int dwSubscriberNumberOffset;
}

private class NativeTapi
{
[DllImport("coredll")]
public static extern int lineClose(IntPtr hLine);

[DllImport("cellcore")]
public static extern int lineGetGeneralInfo(IntPtr hLine, byte[] bytes);

[DllImport("coredll")]
public static extern int lineGetAddressCaps(IntPtr hLineApp, int dwDeviceID, int dwAddressID, int dwAPIVersion, int dwExtVersion, byte[] lpAddressCaps);

[DllImport("coredll")]
public static extern int lineInitializeEx(out IntPtr lpm_hLineApp, IntPtr hInstance, IntPtr lpfnCallback, string lpszFriendlyAppName, out int lpdwNumDevs, ref int lpdwAPIVersion, ref LINEINITIALIZEEXPARAMS lpLineInitializeExParams);

[DllImport("coredll")]
public static extern int lineNegotiateAPIVersion(IntPtr m_hLineApp, int dwDeviceID, int dwAPILowVersion, int dwAPIHighVersion, out int lpdwAPIVersion, out LINEEXTENSIONID lpExtensionID);

[DllImport("coredll")]
public static extern int lineOpen(IntPtr m_hLineApp, int dwDeviceID, out IntPtr lphLine, int dwAPIVersion, int dwExtVersion, IntPtr dwCallbackInstance, int dwPrivileges, int dwMediaModes, IntPtr lpCallParams);

[DllImport("coredll")]
public static extern int lineShutdown(IntPtr m_hLineApp);
}
}

Add remider function in Windows Mobile application

I need to do this.

Friday, February 6, 2009

How to access the file system on Windows Mobile 5 Smartphone emulator

Here is the short description about how to access the file system on Windows Mobile emulator.

If your application is using data files or images, you need to copy them in a memory for the emulator.

I assume that you use Visual Studio 2005, you didn't connect any mobile device to your desktop, and you have already installed ActiveSync.

Here is simple procedure.
1. Under "Tools" in Visual Studio 2005, select "Device Emulator Manager".
2. Scroll down the list of emulated devices until you see what you want to use.
(i.e., I selected "Windows Mobile 5.0 Smartphone Emulator".)
3. Under "Actions" in the emulator manager, select "Connect". Then, an emulator will pop up.
4. Under "Actions" in the emulator manager, select "Cradle".
5. Now open ActiveSync. Under "File" in ActiveSync, select "Connection Settings". Check "Allow connections to one of the following" and select "DMA". You only need to do this once. When you click “Connect” in ActiveSync, it connects to the emulator and give you some setup screens. After the first time, the connection happens automatically when you “cradle” the emulator via the Device Emulator manager.
6. Now you can browse the file system on the emulator by selecting “Explore” on ActiveSync (or
selecting “Mobile Device” from My Computer). By default, your application is deployed to
“Program Files\[your application name]”.

Reference: http://inst.eecs.berkeley.edu/~cs160/sp06/section/vstutorial.pdf