サンプルコード
https://onedrive.live.com/?cid=6243a854f0391367#cid=6243A854F0391367&id=6243A854F0391367%21124
protected void onHandleIntent(Intent intent) {
long kidou = getPreLong(teisu);
if(kidou==0L){//0Lなら終了
return;
}
try{
manager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
//manager.requestLocationUpdates(LocationManager.GPS_PROVIDER,0,0,this);
//GPSがオフの場合は終了
if(manager.isProviderEnabled(LocationManager.GPS_PROVIDER)==false){
manager.removeUpdates(this);
return;
}
final Looper looper = Looper.getMainLooper();
listener = this;
new Thread(new Runnable() {
public void run() {
// LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
manager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,listener,looper);
// retrieveUserId();
//sendData(user_id);
}
}).start();
//使用していない
class LooperThread extends Thread {
public Handler mHandler;
public void run() {
Looper.prepare();
mHandler = new Handler() {
public void handleMessage(Message msg) {
// process incoming messages here
manager.requestLocationUpdates(LocationManager.GPS_PROVIDER,0,0,listener);
}
};
Looper.loop();
}
}
}catch (Exception e) {
e.printStackTrace();
}
}
0 件のコメント:
コメントを投稿