Skip to content Skip to sidebar Skip to footer

Find Location Of Mobile

I want to find latitude & longitude when I enter the mobile number. There is any way to do that in android?

Solution 1:

Mhhhmm... Hopefully I will tell you can do that always provided the following,

  • You own the Phone
  • You have installed an mobile application (Paid the better) already
  • You are not prohibited by law for this

As far as Coding,

Here is a sample code.

Main Activity:

package com.schogini.SimpleTracker;

import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;

import android.app.Activity;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.telephony.gsm.SmsManager;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.widget.Toast;

publicclassLaunchActivityextendsActivity {
    Context ctx;
    String imei="1234567890";
    String[] lv_arr,lstr; 
    int smscount=1;
    double xpin=0.0,ypin=0.0;
    SQLiteDatabase dbb;
    Cursor cur;
    TelephonyManager tmgr;

    /** Called when the activity is first created. */@OverridepublicvoidonCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        tmgr = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
        //getting GPS dataLocationManagermlocManager= (LocationManager)getSystemService(Context.LOCATION_SERVICE);
        LocationListenermlocListener=newMyLocationListener();
        mlocManager.requestLocationUpdates( LocationManager.GPS_PROVIDER, 0, 0, mlocListener);
        //Exit program when Mission accomplished
        LaunchActivity.this.finish();
    }

    privatevoidsendSMS(String phoneNumber, String message)
    {      
        StringSENT="SMS_SENT";
        StringDELIVERED="SMS_DELIVERED";

        PendingIntentsentPI= PendingIntent.getBroadcast(this, 0,
            newIntent(SENT), 0);

        PendingIntentdeliveredPI= PendingIntent.getBroadcast(this, 0,
            newIntent(DELIVERED), 0);

        //---when the SMS has been sent successfully---
        registerReceiver(newBroadcastReceiver(){
            @OverridepublicvoidonReceive(Context arg0, Intent arg1) {
                switch (getResultCode())
                {
                    case Activity.RESULT_OK:
                    {
                        Toast.makeText(getBaseContext(), "SMS sent", 
                                Toast.LENGTH_SHORT).show();
                        //sent=1;break;
                    }
                    case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
                    {
                        Toast.makeText(getBaseContext(), "Generic failure", 
                                Toast.LENGTH_SHORT).show();
                       // sent=0;break;
                    }
                    case SmsManager.RESULT_ERROR_NO_SERVICE:
                    {
                        Toast.makeText(getBaseContext(), "No service", 
                                Toast.LENGTH_SHORT).show();
                        //sent=0;break;
                    }
                    case SmsManager.RESULT_ERROR_NULL_PDU:
                    {
                        Toast.makeText(getBaseContext(), "Null PDU", 
                                Toast.LENGTH_SHORT).show();
                       // sent=0;break;
                    }
                    case SmsManager.RESULT_ERROR_RADIO_OFF:
                    {
                        Toast.makeText(getBaseContext(), "Radio off", 
                                Toast.LENGTH_SHORT).show();
                       // sent=0;break;
                    }
                }
            }
        }, newIntentFilter(SENT));

        //---when the SMS has been delivered---
        registerReceiver(newBroadcastReceiver(){
            @OverridepublicvoidonReceive(Context arg0, Intent arg1) {
                switch (getResultCode())
                {
                    case Activity.RESULT_OK:
                    {
                        Toast.makeText(getBaseContext(), "SMS delivered", 
                                Toast.LENGTH_SHORT).show();
                        //delivered=1;break;
                    }
                    case Activity.RESULT_CANCELED:
                    {
                        Toast.makeText(getBaseContext(), "SMS not delivered", 
                                Toast.LENGTH_SHORT).show();
                       // delivered=0;break;
                    }                   
                }
            }
        }, newIntentFilter(DELIVERED));        

        SmsManagersms= SmsManager.getDefault();
        sms.sendTextMessage(phoneNumber, null, message, sentPI, deliveredPI);     
    }
    /* Class My Location Listener for GPS and location*/publicclassMyLocationListenerimplementsLocationListener{
        @OverridepublicvoidonLocationChanged(Location loc){
            double pinx=0.0, piny=0.0;
            pinx=loc.getLatitude();
            piny=loc.getLongitude();
            Stringloca="My current location is: " +
            "Latitude = " +pinx +
            "Longitude= " + piny;
            Toast.makeText( getApplicationContext(),
                    loca,
                    Toast.LENGTH_LONG).show();
            if(xpin!=pinx||ypin!=piny)
            {
                lstr[0]="GPS Latitude = " + loc.getLatitude() +" Longitude= " + loc.getLongitude();
                sendSMS("5556", " "+lstr);
            }           
                xpin=loc.getLatitude();
                ypin=loc.getLongitude();
                loca = "My old location is: " +
                "Latitude = " +xpin +
                "Longitude= " + ypin;
                Toast.makeText( getApplicationContext(),
                        loca,
                        Toast.LENGTH_LONG).show();
        }
        @OverridepublicvoidonProviderDisabled(String provider){
            Toast.makeText( getApplicationContext(),
                    "GPS Disabled",
                    Toast.LENGTH_SHORT ).show();
        }
        @OverridepublicvoidonProviderEnabled(String provider){
            Toast.makeText( getApplicationContext(),
                    "GPS Enabled",
                    Toast.LENGTH_SHORT).show();
        }
        @OverridepublicvoidonStatusChanged(String provider, int status, Bundle extras){
        }
     }/* End of Class MyLocationListener */
}

Sample Coding For receiving Boot Completed:

package com.schogini.SimpleTracker;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

publicclassMyIntentReceiverextendsBroadcastReceiver {
//  Called when boot completes@OverridepublicvoidonReceive(Context context, Intent intent) {
//      Set what activity should launch after boot completesIntentstartupBootIntent=newIntent(context, LaunchActivity.class);
        startupBootIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(startupBootIntent);
    }
}

XML Coding: (AndroidManifest.xml)

<?xml version="1.0" encoding="utf-8"?><manifestxmlns:android="http://schemas.android.com/apk/res/android"package="com.schogini.SimpleTracker"android:versionCode="1"android:versionName="1.0"><applicationandroid:icon="@drawable/icon"android:label="@string/app_name"><activityandroid:name=".LaunchActivity"android:label="@string/app_name"><intent-filter><actionandroid:name="android.intent.action.MAIN" /></intent-filter></activity><receiverandroid:name="MyIntentReceiver"><intent-filter><actionandroid:name="android.intent.action.BOOT_COMPLETED" /><categoryandroid:name="android.intent.category.HOME" /></intent-filter></receiver></application><uses-sdkandroid:minSdkVersion="3" /><uses-permissionandroid:name="android.permission.RECEIVE_BOOT_COMPLETED" /><uses-permissionandroid:name="android.permission.SEND_SMS" /><uses-permissionandroid:name="android.permission.ACCESS_FINE_LOCATION" /><uses-permissionandroid:name="android.permission.READ_PHONE_STATE" /><uses-permissionandroid:name="android.permission.ACCESS_COARSE_LOCATION" /><uses-permissionandroid:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" /><uses-permissionandroid:name="android.permission.ACCESS_COARSE_UPDATES" /></manifest>

Some Applications:

WaveSecure From McAfee

https://www.wavesecure.com/

Mobile Defense:

https://www.mobiledefense.com/

Lookout:

https://www.mylookout.com/

Prey:

http://preyproject.com/

Theft Aware:

https://www.theftaware.com/?step=start

wheresmyandroid

http://www.appbrain.com/app/wheres-my-droid/com.alienmanfc6.wheresmyandroid

If you lost the phone already, complaint to the Police/cyber department. You cannot manually trace it.

It is recommended to buy a similar app so that there is chance to trace your phone and erase your sensitive data. A small investment in such apps would be handy always.

Solution 2:

No.

Impractical exceptions to the above answer.

  • You are a telecommunication company, then you can do triangulation between the phone and the nearby cell towers.

  • You are law enforcement, then ask the telecommunication company (will usually need subpoena).

  • You find a way to hack the phone remotely (e.g. using booby trapped webpage), and then turn on it's GPS and get it to send back an answer.

Post a Comment for "Find Location Of Mobile"