Hi Friends, if you like my blog please give your valuable comments it will help to improve my blog content and enthusiasm to write a lot in android World.

Thursday, January 31, 2013

Android-Remote Debugging in chrome

You can debug mobile web sites with the full suite of Chrome Developer Tools running on a desktop browser that's connected to your phone via USB. View and change HTML code and styles until you get a bug-free page that behaves perfectly on the phone or tablet.

Know more: https://developers.google.com/chrome/mobile/docs/debugging 

Wednesday, January 2, 2013

Calling system settings from an Android app - GPS example



This tutorial shows how to redirect the user to a system settings screen asking to modify some settings the application depends on. We will make a specific example with Gps: The application can be used only if gps is available.
The android system gps setting screen can be called just like any other Activities:
  1. startActivityForResult(newIntent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS), 0);
To check GPS availability use the code code below: (the Activity must implement LocationListener)
  1. LocationManager locationManager = (LocationManager)getSystemService(LOCATION_SERVICE);
  2. locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000L,1.0f, this);
  3. boolean isGPS = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
The example application will do the following:
1. On application start check if gps is available. If it is on the application can proceed.
2. If GPS is turned off, display a dialog asking the user to turn it on, and 2 buttons, one to go to GPS settings screen, and a cancel button to exit the application.
3. When the dialog is displayed we must store in a variable that the user was already asked once to turn on GPS
4. If the user leaves to the GPS option screen, it is not sure that he will turn on the GPS!
5. When the user returns to  application we recheck the GPS. If its available we can proceed, otherwise we close the application. (in order to check that it is a returm to the activity or is it its first start we check the variable we set in step 3)
So we will have the code in the applications starting Activity's on Resume method, where we will detect GPS availability, use a dialog to ask the user, an Intent to go to options screen, and a variable to indicate the state of the GPS turn on process. The code for this example application is available here. Turn off your GPS and try running it.