Mobile phone anti-theft acquisition of mobile phone longitude and latitude

Source: Internet
Author: User

There are three methods for obtaining the mobile phone longitude and latitude: GPS, network, and base station. We can obtain the best Positioning Method Based on the positioning conditions. Then, the obtained longitude and latitude information is sent to the specified mobile phone number.

/** Only one instance can exist in a single State. * Get the GPS information of the mobile phone */public class gpsinfoservice {private context; private locationmanager; sharedpreferences sp; // Private gpsinfoservice (context) {This. context = context; Manager = (locationmanager) context. getsystemservice (context. location_service); SP = context. getsharedpreferences ("Config", context. mode_private);} Private Static gpsinfoservice mgpsservice; Public synchronized static gpsinfoservice getinstance (context) {If (mgpsservice = NULL) mgpsservice = new gpsinfoservice (context); Return mgpsservice ;} /** the positioning methods supported by your mobile phone can be obtained. * There are multiple positioning methods, such as GPS network, base station, and passive. * Based on the positioning conditions, obtain the best Positioning Method */Public void registerlocationupdates () {Criteria = new criteria (); // sets the positioning precision to criteria. setaccuracy (criteria. accuracy_coarse); // obtain the approximate location criteria. setaltituderequired (false); // The elevation information criteria. setcostallowed (true); // charges are allowed for criteria. setpowerrequirement (criteria. power_low); // Low Power // gets the provider string provider = manager for the location that best matches the query conditions. getbestprovider (criteria, true); // when the position changes, the linster listener is called to obtain the longitude and latitude manager. requestlocationupdates (provider, 60000, 0, getlinster ();} public void canclelocationupdates () {manager. removeupdates (getlinster ();} Private Static mygpslinster mygpslinser; private mygpslinster getlinster () {If (response = NULL) mygpslinser = new mygpslinster (); Return mygpslinser ;} private class mygpslinster implements locationlistener {// callback method when the user's location changes public void onlocationchanged (location) {// obtain the user's latitude double latitude = location. getlatitude (); // obtain the user's longitude double longpolling = location. getlongationstr = "Jing Du" + longpolling + "weidu:" + latitude; Editor editor = sp. edit (); Editor. putstring ("lastlocation", locationstr); Editor. commit ();} // status change public void onstatuschanged (string provider, int status, bundle extras) {// todo auto-generated method stub} // GPS, open public void onproviderenabled (string provider) {// todo auto-generated method stub} // close public void onproviderdisabled (string provider) {// todo auto-generated method stub}/*** get the last location of the phone * @ return */Public String getlastposition () {return sp. getstring ("lastlocation ","");}}

Obtain the latitude and longitude of the text message and send the obtained latitude and longitude to the specified number:

// Obtain the longitude and latitude of the current mobile phone. gpsinfoservice. getinstance (context ). registerlocationupdates (); // sends the longitude and latitude information to the security number, obtains the text message sender, and sends the text message to the specified smsmanager = smsmanager. getdefault (); smsmanager. sendtextmessage ("15287978798", null, gpsinfoservice. getinstance (context ). getlastposition (), null, null );

 

Do you want to achieve your goals and dreams quickly? Please add QQ: 673220883 every day provides you with a lot of inspirational, video, sales, management, and other-classic articles, free to learn. This QQ space has changed the fate of tens of millions of people. Chen anzhi and you start your dream journey! National Course Registration Hotline: 131
6187 6870

 

Wonderful Sharing: if you have no goals, you will be confused about the future.

Wonderful Sharing: Yu hongmin: only one thing in my life
Don't think too much

Wonderful Sharing: Man's one hundred secrets are impossible to know without saying it!

Wonderful Sharing: Do not make these regrets the 25 most regrettable events before your death
It's your pity

Wonderful Sharing: six steps will help you break the chat embarrassment. We recommend you read the wonderful sharing:
Tell yourself that I can lose, but I will never give up on sharing highlights: business experts do not want others to know about the secrets of communication. Wonderful Sharing: Chen anzhi teaches you how to earn 5 million by the age of thirty, it may take a few minutes for both men and women to read the story of Steve Jobs! Stanford University speech: delay equals death-a course that changes ten millions of lives! Wonderful Sharing: Why are you a talented poor? Articles that benefit you for life! Wonderful Sharing: Life is like a cup of tea. It won't cry for a lifetime, but it will always cry for a while!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.