Wednesday, November 7, 2012

Android WiFi BroadCast Lock

If you want to get the broadcast IP address from a wifi access point you must first request a wifi multicast lock on the device. Android by default filters out UDP broadcast packets.

Follow these steps:

 1. first add the following to your android Manifest.xml file:

  2. Second copy this method into your activity or service class: 

public void getMultiCastLock() {
 WifiManager wim= (WifiManager) _androidContext.getSystemService(Context.WIFI_SERVICE);
 /* Turn off multicast filter */ 
_mcastLock = wim.createMulticastLock(Context.WIFI_SERVICE);
 *NOTE:replace _androidContext with your local context object;

 3. Copy this method and call it after you acquire the lock

public String getBroadcastAddress() {
 InetAddress currentInetAddress = null;
 String returnValue = "";
 WifiManager myWifiManager = (WifiManager) _androidContext.getSystemService(Context.WIFI_SERVICE);
 DhcpInfo myDhcpInfo = myWifiManager.getDhcpInfo(); 
if (myDhcpInfo == null) {
 System.out.println("Could not get broadcast address");
 return null;
 int broadcast = (myDhcpInfo.ipAddress & myDhcpInfo.netmask) | ~myDhcpInfo.netmask; byte[] quads = new byte[4];
 for (int k = 0; k < 4; k++)
 quads[k] = (byte) ((broadcast >> k * 8) & 0xFF);
 try {
 currentInetAddress= InetAddress.getByAddress(quads);
 } catch (Exception e) {
 if(currentInetAddress != null){ returnValue = currentInetAddress.toString().substring(1);
 return returnValue;

 4. After you are finished. You must release the lock.

Tuesday, May 1, 2012

Deploying SSAS MDX Script file through XMLA

Greate post detailing how to use SQL Server Profiler to capture the XMLA from BIDS Helper and using it to update SSAS cube calculations using a script.

Thursday, November 18, 2010

Threads in Android - ProgressDialog showing up all late

If you need to display a progress bar and its not showing up and your code done executing, then you need to learn threads. You have to execute your long running code in a sperate thread (downloading data, saving user perferences, i.e., any long running process). However, you cannot update the UI in your new thread. You will have to create a 'Handler' and post messages from your new thread. The handler will hand the message off to the UI/calling thread. I learned all of this from here: simple progress bar dialog in android with thread

Tuesday, October 12, 2010

Android emulator reports unknown virtual device name

Android emulator reports unknown virtual device

Are you getting the following error:
emulator: ERROR: unknown virtual device name: 'Android21Device'
emulator: could not find virtual device named 'Android21Device'

Well the emulator is C app and the android tool is a Java app so they
have slightly different ways to get your user profile directly.

Out of curiosity, if you do a "set" under a command-prompt, what is
your USERPROFILE variable?

Your best solution is to define a global environement variable ANDROID_SDK_HOME.

To do that: Start > Control Panel > System > Advanced System Settings

> Environment Variables. Create a new user one called

"ANDROID_SDK_HOME" and set it to the path where you want .android to
be created, e.g. maybe "d:\"

Google Groups
Stack Overflow

Saturday, July 31, 2010

Receiving 'Validation of viewstate MAC failed' for sites migrated form .NET 1.1 to 3.5 IIS7

The below saved me a lot of time!!


Validation of viewstate MAC failed after installing .NET 3.5 SP1
Tess Ferrandez 14 Apr 2009 8:04 AM
Comments 42
After installing .NET 3.5 SP1 you may get Validation of viewstate MAC failed exceptions when doing post backs on ASP.NET pages

Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.
Stack Trace:

[HttpException (0x80004005): Unable to validate data.]
System.Web.Configuration.MachineKeySection.GetDecodedData(Byte[] buf, Byte[] modifier, Int32 start, Int32 length, Int32& dataLength) +289
System.Web.UI.ObjectStateFormatter.Deserialize(String inputString) +140

[ViewStateException: Invalid viewstate.
Client IP:
Port: 34562
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.2; WOW64; .NET CLR 2.0.50727; .NET CLR 1.1.4322; InfoPath.2; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.590; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; Zune 3.0; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; MS-RTC LM 8)
ViewState: /wEPDwUKMTc2NzE0NzA0NmRkmWc0SFS8H55FfURfpUekG2KhS8g=
Referer: http://localhost/MySite/Default3.aspx
Path: /MySite/Default.aspx]

[HttpException (0x80004005): Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.]
System.Web.UI.ViewStateException.ThrowError(Exception inner, String persistedState, String errorPageMessage, Boolean macValidationError) +106
System.Web.UI.ViewStateException.ThrowMacValidationError(Exception inner, String persistedState) +14
System.Web.UI.ObjectStateFormatter.Deserialize(String inputString) +242
System.Web.UI.ObjectStateFormatter.System.Web.UI.IStateFormatter.Deserialize(String serializedState) +4
System.Web.UI.Util.DeserializeWithAssert(IStateFormatter formatter, String serializedState) +37
System.Web.UI.HiddenFieldPageStatePersister.Load() +207
System.Web.UI.Page.LoadPageStateFromPersistenceMedium() +105
System.Web.UI.Page.LoadAllState() +43
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +6785
System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +242
System.Web.UI.Page.ProcessRequest() +80
System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +21
System.Web.UI.Page.ProcessRequest(HttpContext context) +49
ASP.default_aspx.ProcessRequest(HttpContext context) +4
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +181
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75


This will happen if you have specified an action on the forms element, and if the action is different than the page you are browsing to, i.e. in this case the page I am browsing to is Default3.aspx, but the action is set to Default.aspx (as you can see from the Path and Referer in the error message)


The reason this occurs after installing SP1 for .NET 3.5 is because prior to this service pack, the action attribute was ignored. Now that it is no longer ignored, the post-back will actually post back to the action page, and of course the view state for Default3.aspx will not be valid for Default.aspx.

You’ve heard it before:) this is not a bug, it’s a feature… in this case that’s actually true…


Remove the action attribute in the HTML or generated HTML from the ASPX page, or change it to post to the right page if you want to have viewstate enabled.


Tuesday, May 4, 2010

Stock Price Alerts - Applicaiton for Android

Are you the type of person who watch the stock market closely? Then get Stock Price Alerts for Android. Its an awsome app that alerts you when a stock moves up or down.

Tuesday, April 20, 2010

Android Stock Alerting Application - Update Released

A new update has been released for Stock Price Alerts (app for the Android Market). The application now supports news headlines. The latest news headlines can be access from any stock in your stock list. Just "long press" any stock and the "More Actions" menu will appear. Then tap "Get latest news headlines"!

Thursday, April 1, 2010

Code Sign error: Provisioning Profile cannot be found

If you get this crappy message from XCode because you updated your provisioning profile, then do the following.

In XCode, in the "Groups & Files" pane, expand "Targets" and double-click on your app's target.

This will bring up the Info pane for your target. In the "Build" section, check the "code signing" section for any old profiles. I found that it was building to an old profile there.


Friday, March 19, 2010

Android Stock Alerting Application

AlienHive Labs just released its first application - Stock Price Alerts.

What is Stick Price Alerts?
Stock Price Alerts is a simple and easy to use application that notifies you when a stock has hit it's configured low or high price. How you ask? After you setup your stock list (ticker, low/high prices, and enable notifications) you can enable the alerting system to automatically update your stock list. The alerting system will run in the background pulling data from the Internet. A notification will be sent once a stock has hits its low or high price.

More information: