[Android] mobile guard mobile phone realizes SMS command to obtain location

Get location

Create a new service package

Create a new gpsservice class to inherit the service class of the system

Register in the manifest file

Override the oncreate () method to call back when the service is created

Override the ondestroy () method to call back when the service is destroyed

Take the code from the previous section to this place

Get the last location after the user moves and save it to sp

Convert the standard coordinates to Mars coordinates, put the database file in the assets directory, and put modifyoffset.java under the service package

Get the modifyoffset object through the modifyoffset. Getinstance() method. Parameters: input stream; Convert the file in the asset directory into an input stream, and use getassets(). Open ("file name") to get the InputStream object,

Call the S2C () method of modifyoffset object and convert the standard to Chinese to get a new pointdouble object. Parameters: pointdouble object, x, y

Gets the y value of the longitude ponitdouble object

Gets the X of the latitude ponitdouble object

Save location data to sp

Receive instruction and send location SMS

Start the service, get the intent object at the place where the SMS is received, and call the startservice () method of the context object

Gets the location information saved in the sp

Send SMS, smsmanager. Getdefault(). Sendtextmessage() method, send SMS to security number, parameters: sendtextmessage (target mobile phone, null (source mobile phone does not support), text, sendintent, deliveryintent), the last two parameters, delay report and delivery report, don't care to fill in null

This permission is required android.permission.send_ SMS

Judge whether the content is empty. If it is empty, the SMS content is being obtained. Manually change the coordinates to get it

GPSService.java

SmsReceiver.java

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>