Saturday, April 23, 2011

iPhone and Android smartphones track and store your locations

Got an iPhone or iPad ?
You would be surprised to know that iPho is regularly tracking down your location. What makes the situation more worst and worrying is that is the file is unencrypted and unprotected, and it's on any machine you've synched with your iOS device. Anybody with access to this file knows where you've been over the last year, since iOS 4 was released.

Is it really dangerous? May be not, look at following link
for more information:

Android is tracking your location too:
A security researcher has discovered that smartphones running Google's Android operating system are tracking users' locations and storing that data in files on the phone. This news comes only days after it became widely known that a similar file on Apple's iPhone also logs a complete history of users' travels by way of timestamped latitude and longitude coordinates.

Two files called cache.cell and cache.wifi located in the /data/data/ directory on Android phones contain records of the last 50 cell towers the device has communicated with and the last 200 Wi-Fi networks the phone has discovered, respectively.
However, unlike the file found on the iPhone, this data is overwritten as the files become full. Accessing the file also requires full administrator privileges (aka, "root" access) to the device in question.

Is this really invasion of privacy?
Can this information be misused in future?

Question is what should be done now, good thing is, this has caught public's eye. Lets see what is smartphone makers next move.

Wednesday, April 20, 2011

How to execute service once every day on Android?

I am trying to search for a solution which can help me execute a task every day on Android once on predefined time. I found a link which might help.

I am still working on the solution. Lets hope above link helps.

Tuesday, April 19, 2011

Why do you get android.os.NetworkOnMainThreadException?

This exception is only thrown for applications targeting the Honeycomb (Android 3) SDK or higher. Applications targeting earlier SDK versions are allowed to do networking on their main event loop threads, but it's heavily discouraged. See the document Designing for Responsiveness. See API documentation at below link for more information:


The exception that is thrown when an application attempts to perform a networking operation on its main thread.

How to fix it?

You must either use a handler or a AsyncTask. Check out this site for tutorials (

I used the AsyncTask method. I created a CustomAsyncTask class, Extended AsyncTask class and just put everything inside the doInBackground(String[]) method. Once created, a task is executed very simply: new CustomAsyncTask().execute(...);
It till need to fine tune my logic to work with AsyncTask but at least I was able to make my code work.

You can also use StrictMode to detect such issues. StrictMode is a developer tool which detects things you might be doing by accident and brings them to your attention so you can fix them.
StrictMode is most commonly used to catch accidental disk or network access on the application's main thread, where UI operations are received and animations take place. Keeping disk and network operations off the main thread makes for much smoother, more responsive applications. By keeping your application's main thread responsive, you also prevent ANR dialogs from being shown to users.

If you find violations that you feel are problematic, there are a variety of tools to help solve them: threads, Handler, AsyncTask, IntentService, etc. But don't feel compelled to fix everything that StrictMode finds.

StrictMode is not a security mechanism and is not guaranteed to find all disk or network accesses. While it does propagate its state across process boundaries when doing Binder calls, it's still ultimately a best effort mechanism.
To know more about StrickMode visit link:

Monday, April 18, 2011

How to remove App from Android Emulator

First,make sure the emulator is running. Then follow below steps:
1. go to tools directory in command
2. adb shell
3. cd /data/app
4. ls (It will display all the .apk installed in your emulator)
5. rm ***.apk(which you want to remove)
6. exit

One more way is to delete the Andoird image file which looks like “userdata-qemu.img” and at can be found in “C:\Users\\AppData\Local\Android”.

The other option is enable “-wipe-data” param in your emulator start up profile.

Sunday, April 17, 2011

How to make Android Emulator Run Faster?

I noticed Android emulator startup was very slow. Even after starting, navigating apps was also slow.

I tried following tweaks on Android 3.0 (HoneyComb) emulator to speed up the emulator but above tweaks should work on any android emulator which supports snapshots.

I was looking for the solution and I learnt following few good tricks from Android blogs:
Use this options whilte starting eumlator:
emulator -cpu-delay 0 -no-boot-anim -cache ./cache -avd avd_name


emulator -cpu-delay 0 -no-boot-anim -cache ./cache -scale 0.8 -avd avd_name
You can also use Android Snapshot feature described here.

Or you can follow below steps to enable snapshot feature:
  1. When creating (or editing) an AVD, tick the 'Snapshot enabled' box.
  2. The launch dialogue for a snapshot-enabled AVD will offer additional 'Launch from snapshot' and 'Save to snapshot' options.
  3. The first time a snapshot-enabled AVD is launched, there is no snapshot data so it will boot normally. Pressing the close button will save the state (if that's been selected) and then quit the emulator.
Once the snapshot has been saved loading is faster.

Other points to note with snapshot AVDs:
  • If you want to reboot the phone, you need to un-tick the 'Load from snapshot' option.
  • The time is corrected to the current time of day from the emulated cell tower, on average after 8 seconds after restore.
  • Some emulated systems, like cell tower strength, may not be saved to the snapshot, and will restore with the emulator's default setting.
Issues faced:
While I was debugging my code, I was making lots of code changes and reloading my app again and again from eclipse. I noticed due to above tweaks may be my app was not getting reloaded properly. I was playing around with Android Sync provider may be due to that I was facing these issue.

Friday, April 15, 2011

Sharing learnings I had while working on Microsoft Sync Framework 4.0 (CTP)

Recently, I started using Microsoft Sync Framework 4.0 (CTP). I faced many issues in the begining when I was configurating it. There were some basic doubts in my mind about what it can do and what it can not do. Basically, what should I expect from it.

Following are list of questions (FAQs) I had and answers I found from Sync documentation, official forums and blogs:
  • Does Microsoft Sync Framework 4.0 need to talk to SQL Server directly? Is it possible if I introduce SOA layer between Microsoft Sync Framework 4.0 and SQL Server?
yes it needs to. it needs to ask the database server what to sync. if you dont want to use the built-in providers, you can write your own, but then, Sync Fx will still need to talk to your provider and your provider to SQL.
the WCF-based sync service already provides a good abstraction to the back-end database such that the client need only know the service and not where and what the database is.
  • How can Android talk to Microsoft Sync framework?
No, we just didnt have the time/expertise in the team to generate an Android sample. I think there are some c# to Java source code converters that you may employ to convert the Wm6.5 sample. This should give you a good starting point for the Android sample.
if you are looking for pure Android code I can´t help you but for MonoDroid there is a nice solution which already supports the sync framework 4.0 CTP. I am currently evaluating this nice oodb called siaqodb. For more informations goto
  • What work does 'SyncSvcUtil.exe' utility do to instrument the database?
SyncSvcUtil is just a utility to provision/deprovision scopes, generate code for WCF-based sync service, isolated store and client entities.
The only changes that we do to the database when you use SyncSvcUtil is to use the SqlSyncScopeProvisioning/SqlSyncScopeDeProvisioning API's from SyncFx 2.1 to provision/deprovision the database based on the request.
This means that we create insert/update/delete triggers, tracking tables and few stored procedures per table for change tracking/enumeration/change application purposes. This is exactly similar to what you would have done, had you used SyncFx 2.1 to manually provision the database.
  • How can I disable this redirection to $syncscopes???
A service that is generated by SyncFx 4.0 CTP only uses OData as the wire format since it is a widely recognized format for representation od data. The SyncFx service does not perform OData operations as documented in instead it only knows how to upload and download incremental changes. To make this possible, we made some additions to the OData format to support sync specific constructs like knowledge, tombstones etc. The redirection to $syncscopes is our way of letting you discover what scopes are available for sync from the service. Internally, the service uses Sync Framework 2.1 database providers.
  • Issue faced: Server error in fetching remote contacts: HTTP/1.1 500 Internal Server Error
Following steps fixed the issue for me:
I had installed 32 bit version of Sync Framework 2.1 SDK. Installation was successful for me so I thought things are working fine until I got HTTP 500 error. 500 error appears usually if something is wrong on server side.
I removed total Microsoft Sync Framework 4.0 (CTP) and installed freshly as mentioned in download instructions for 64 bit installation. That worked for me. See following link for more information regarding the issue.
If server side setup is proper then make sure IIS application pool's Process Model is set to LocalSystem. This will not be that secure but check it to make sure things are working fine on IIS side.
If that is done and still you are facing issue then make sure you have done as follows:
1. Launch SQL Server Management Studio.
2. Expand Security, right-click Logins, and then click New Login.
3. Enter NT AUTHORITY\NETWORK SERVICE for the Login name, switch to the User Mapping tab.
4. Select listdb from the database list and select db_owner from the role list, and then click OK.

Example code to connect node.js REST service with Eureka discovery service

Eureka is Spring based discovery service developed by Netflix. To know how Eureka is used at Netflix visit: