Skip to main content

How to take raw data from an android mobile phone's GPS..?

Hello friends
                        Today i am gonna to discuss about taking raw data or coordinate from an android mobile GPS device.

Let's Start................

Step:1


Just enter into programming mode in android studio.
If you don't know that how to do that please read this post.

Step:2



Now just make a new class as show in figure and name it BootService.

Step:3

Now extends Service and implements LocationListener as shown in figure below.


Step:4

Now just copy and paste following code into BootService class.




LocationManager lm;


@Override
public int onStartCommand(Intent intent, int flags, int startId)
{

lm = (LocationManager) getSystemService(LOCATION_SERVICE);
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 1, this);

return START_STICKY;
}

@Override
public void onLocationChanged(Location location) {

try{

Toast.makeText(this, "GPS Values Found: " + String.valueOf(location.getLongitude()) + " : " + String.valueOf(location.getLatitude()), Toast.LENGTH_SHORT).show();
}catch(Exception ex){
Log.i("Error in getting location valus", ex.getMessage());
}
}

@Override
public void onProviderDisabled(String provider) {
/* this is called if/when the GPS is disabled in settings */

/* bring up the GPS settings */
//Intent intent = new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
//startActivity(intent);
Toast.makeText(this, "GPS Disabled", Toast.LENGTH_SHORT).show();
}

@Override
public void onProviderEnabled(String provider) {
Toast.makeText(this, "GPS Enabled", Toast.LENGTH_SHORT).show();
}

@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
/* This is called when the GPS status alters */
switch (status) {
case LocationProvider.OUT_OF_SERVICE:
Toast.makeText(this, "Status Changed: Out of Service",
Toast.LENGTH_SHORT).show();
break;
case LocationProvider.TEMPORARILY_UNAVAILABLE:
Toast.makeText(this, "Status Changed: Temporarily Unavailable",
Toast.LENGTH_SHORT).show();
break;
case LocationProvider.AVAILABLE:
Toast.makeText(this, "Status Changed: Available",
Toast.LENGTH_SHORT).show();
break;
}
}


@Override
public IBinder onBind(Intent arg0)
{
return null;
}

Step:5

Now Just copy and paste following permissions into manifest file.

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"></uses-permission>

<service android:name=".BootService"></service>



Step:6
Now just connect your mobile phone to pc via USB cable and click on run in android studio.This will install app into your mobile,where you can see GPS values as toast message.

IF YOU HAVE ANY QUERY PLEASE COMMENT BELOW

Comments

Popular posts from this blog

Shows full image when you hover over a thumbnail

By:Prayag nao Thumbnail Zoom Plus   It's a firefox add-ons.Shows full image when you hover over a thumbnail. Works with Amazon, Baidu Images, Bing Images, Facebook, Flickr, Google+, Google Images, IMDb, LinkedIn, Netflix, Pinterest, Reddit, Twitter, Yandex, YouTube, Wikipedia, Yahoo Images, & many more.     About this Add-on Thumbnail Zoom Plus is a Firefox plug-in which shows a full-size image popup when you hover over a thumbnail or image link. When you hover your mouse over a thumbnail or a link to an image or YouTube video, the add-on displays the full-size image or video still-frame in a floating window. The image remains visible until you move the mouse outside the thumb, click the mouse, or press Escape. It’s quick and easy to move the mouse from one thumbnail to another to see the corresponding full-size images. For details see  User Manual . Supported sites include Amazon , Baidu , Bing , Facebook , Flickr , Google , Huffington

Here's How This Supercool Hoverboard Works

By:Prayag nao   If you've ever dreamed of cruising around town on a floating skateboard like Marty McFly does in the classic '80s flick "Back to the Future Part II," then you could soon be in luck. A pair of innovators is trying to make the futuristic fantasy of riding a hoverboard into a reality. About two months ago, husband and wife design team Jill and Greg Henderson launched a Kickstarter campaignfor their Hendo Hoverboard, a levitating skateboard that could hit "hoverparks" as early as October 2015. The Kickstarter campaign , which ends Sunday (Dec. 14), has been a resounding success, bringing in well over its initial goal of $250,000 in its first week. With only a couple of days to go in the impressive crowdfunding campaign, the project has already raised nearly $500,000. But with all the hype comes an important question: How in the world does this thing work? The basic premise behind the technology is something called

Real life Jarvis-Talk With Your Computer like Jarvis in Iron Man ....!

By:Prayag nao                                            Code to Make your Computer like Jarvis New Speech macro..>> Choose Advanced and change the code like this.. <speechMacros>   <command>     <listenFor></listenFor>   </command> </speechMacros> You have to add a commands  <listenFor>........</listenFor> - computer listens the words you specify here and respond accordingly. <speak>............</speak> - computer speaks what is written in this field according to the command which it got. Similarly, You can Edit more commands in the same way.   <speechMacros> <command> <listenFor>What's going on dude</listenFor> <speak>Nothing special tony</speak> </command> </speechMacros> This is just a basic command,If you want more advanced commands.you have to use Java Scripts and VB scripts . Tell me Time : This is d