久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    <bdo id='LpbSi'></bdo><ul id='LpbSi'></ul>
  • <small id='LpbSi'></small><noframes id='LpbSi'>

    <i id='LpbSi'><tr id='LpbSi'><dt id='LpbSi'><q id='LpbSi'><span id='LpbSi'><b id='LpbSi'><form id='LpbSi'><ins id='LpbSi'></ins><ul id='LpbSi'></ul><sub id='LpbSi'></sub></form><legend id='LpbSi'></legend><bdo id='LpbSi'><pre id='LpbSi'><center id='LpbSi'></center></pre></bdo></b><th id='LpbSi'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='LpbSi'><tfoot id='LpbSi'></tfoot><dl id='LpbSi'><fieldset id='LpbSi'></fieldset></dl></div>

    1. <legend id='LpbSi'><style id='LpbSi'><dir id='LpbSi'><q id='LpbSi'></q></dir></style></legend>
      <tfoot id='LpbSi'></tfoot>

        如何通過其 android id 獲取 android 設備的位置

        How to get location of android device by its android id(如何通過其 android id 獲取 android 設備的位置)

          • <bdo id='dFpuM'></bdo><ul id='dFpuM'></ul>

            <legend id='dFpuM'><style id='dFpuM'><dir id='dFpuM'><q id='dFpuM'></q></dir></style></legend>

            <tfoot id='dFpuM'></tfoot>

                    <tbody id='dFpuM'></tbody>
                  <i id='dFpuM'><tr id='dFpuM'><dt id='dFpuM'><q id='dFpuM'><span id='dFpuM'><b id='dFpuM'><form id='dFpuM'><ins id='dFpuM'></ins><ul id='dFpuM'></ul><sub id='dFpuM'></sub></form><legend id='dFpuM'></legend><bdo id='dFpuM'><pre id='dFpuM'><center id='dFpuM'></center></pre></bdo></b><th id='dFpuM'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='dFpuM'><tfoot id='dFpuM'></tfoot><dl id='dFpuM'><fieldset id='dFpuM'></fieldset></dl></div>

                  <small id='dFpuM'></small><noframes id='dFpuM'>

                • 本文介紹了如何通過其 android id 獲取 android 設備的位置的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我是 android 新手,最近開始學習 Android,我正在嘗試通過其唯一的 android id 獲取任何 android 設備的位置.這樣我就可以通過 GPS 或網絡提供商跟蹤大概或確切的位置.詳細地說,每當我在我的應用程序中輸入任何 Android id 時,我都可以在我的應用程序中獲取設備位置.感謝您的熱心幫助.

                  I am new in android and recently start learning about Android and I am trying to get location of any android device by its unique android id. By that I can track the approx or exact location either by GPS or network provider. In detail I mean to say that whenever i enter any Android id in my app i can get device location in my application. Thanks for your kind help.

                  推薦答案

                  終于可以用這段代碼了:

                  Finally I am able to do with this code:

                  public class MyService extends Service implements LocationListener{
                  String GPS_FILTER = "";
                  Thread triggerService;
                  LocationListener locationListener;
                  LocationManager lm;
                  private static final long MINIMUM_DISTANCE_CHANGE_FOR_UPDATES = 10; // 10 meter
                  
                  private static final long MINIMUM_TIME_BETWEEN_UPDATES = 1000 * 60 * 3; // 1 minute
                  protected LocationManager locationManager;
                  boolean isRunning = true;
                  
                  Calendar cur_cal = Calendar.getInstance();
                  
                  Location location;
                  double latitude; // latitude
                  double longitude;
                  UserFunctions userFunction;
                  private JSONObject json;
                  private AlertDialogManager alert = new AlertDialogManager();
                  
                  private static String KEY_SUCCESS = "success";
                  private static String KEY_ERROR = "error";
                  private static String KEY_ERROR_MSG = "error_msg";
                  private static String KEY_FLAG = "flag";
                  String android_id ;
                  String userName;
                  
                  @Override
                  public void onCreate() {
                      // TODO Auto-generated method stub
                      super.onCreate();
                      Intent intent = new Intent(this, MyService.class);
                      PendingIntent pintent = PendingIntent.getService(getApplicationContext(),
                              0, intent, 0);
                      AlarmManager alarm = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
                  
                      android_id = Settings.Secure.getString(getContentResolver(),
                                  Settings.Secure.ANDROID_ID);
                      if (getAccount() != null) {
                          userName = getAccount();
                      }
                  
                      GPS_FILTER = "MyGPSLocation";
                      // locationManager = (LocationManager)
                      // getSystemService(Context.LOCATION_SERVICE);
                      // locationManager.requestLocationUpdates(
                      // LocationManager.GPS_PROVIDER,
                      // MINIMUM_TIME_BETWEEN_UPDATES,
                      // MINIMUM_DISTANCE_CHANGE_FOR_UPDATES,
                      // new MyLocationListener());
                      cur_cal.setTimeInMillis(System.currentTimeMillis());
                      alarm.setRepeating(AlarmManager.RTC_WAKEUP, cur_cal.getTimeInMillis(),
                              60 * 1000*3, pintent);
                  }
                  
                  @Override
                  public void onStart(Intent intent, int startId) {
                      // TODO Auto-generated method stub
                      super.onStart(intent, startId);
                      //turnGPSOn();
                      /*Toast.makeText(getApplicationContext(), "Hello1", Toast.LENGTH_LONG)
                              .show();*/
                      LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
                       locationListener = new MyLocationListener();
                       locationManager.requestLocationUpdates(
                                  LocationManager.NETWORK_PROVIDER,
                                  MINIMUM_TIME_BETWEEN_UPDATES,
                                  MINIMUM_DISTANCE_CHANGE_FOR_UPDATES, (LocationListener) this);
                       if (locationManager != null) {
                              location = locationManager
                                      .getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
                              if (location != null) {
                                  latitude = location.getLatitude();
                                  longitude = location.getLongitude();
                                  /*Toast.makeText(getApplicationContext(), latitude + ", ll" + longitude, Toast.LENGTH_LONG)
                                  .show();*/
                                  userFunction = new UserFunctions();
                                  new YourAsyncTaskLogin().execute();
                              }
                          }
                  
                       location =locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
                  
                      locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,
                              MINIMUM_TIME_BETWEEN_UPDATES, 1.0f, locationListener);
                  
                  }
                  
                  @Override
                  public void onDestroy() {
                      // TODO Auto-generated method stub
                      super.onDestroy();
                      // removeGpsListener();
                  }
                  
                  
                  
                  @Override
                  public IBinder onBind(Intent intent) {
                      // TODO Auto-generated method stub
                      return null;
                  }
                  
                  // private void removeGpsListener(){
                  // try{
                  // lm.removeUpdates(locationManager);
                  // }
                  // catch(Exception ex){
                  // System.out.println("Exception in GPSService --- "+ex);
                  // }
                  // }
                  
                  private class MyLocationListener implements LocationListener {
                  
                      public void onLocationChanged(Location location) {
                          postdata(location.getLatitude(), location.getLongitude());
                          String message = String.format(
                                  "New Location 
                   Longitude: %1$s 
                   Latitude: %2$s",
                                  location.getLongitude(), location.getLatitude());
                          /*Toast.makeText(MyService.this, message, Toast.LENGTH_LONG).show();
                          turnGPSOff();*/
                      }
                  
                      private void postdata(double latitude, double longitude) {
                          // TODO Auto-generated method stub
                          /*Toast.makeText(getApplicationContext(),
                                  latitude + ", " + longitude, Toast.LENGTH_LONG).show();*/
                      }
                  
                      public void onStatusChanged(String s, int i, Bundle b) {
                          // Toast.makeText(MyService.this, "Provider status changed",
                          // Toast.LENGTH_LONG).show();
                      }
                  
                      public void onProviderDisabled(String s) {
                          // Toast.makeText(MyService.this,
                          // "Provider disabled by the user. GPS turned off",
                          // Toast.LENGTH_LONG).show();
                      }
                  
                      public void onProviderEnabled(String s) {
                          // Toast.makeText(MyService.this,
                          // "Provider enabled by the user. GPS turned on",
                          // Toast.LENGTH_LONG).show();
                      }
                  
                  }
                  
                  public void turnGPSOn() {
                      Intent intent = new Intent("android.location.GPS_ENABLED_CHANGE");
                      intent.putExtra("enabled", true);
                      this.sendBroadcast(intent);
                  
                      String provider = Settings.Secure.getString(getContentResolver(),
                              Settings.Secure.LOCATION_PROVIDERS_ALLOWED);
                      if (!provider.contains("gps")) { // if gps is disabled
                          final Intent poke = new Intent();
                          poke.setClassName("com.android.settings",
                                  "com.android.settings.widget.SettingsAppWidgetProvider");
                          poke.addCategory(Intent.CATEGORY_ALTERNATIVE);
                          poke.setData(Uri.parse("3"));
                          this.sendBroadcast(poke);
                  
                      }
                  }
                  
                  // automatic turn off the gps
                  public void turnGPSOff() {
                      String provider = Settings.Secure.getString(getContentResolver(),
                              Settings.Secure.LOCATION_PROVIDERS_ALLOWED);
                      if (provider.contains("gps")) { // if gps is enabled
                          final Intent poke = new Intent();
                          poke.setClassName("com.android.settings",
                                  "com.android.settings.widget.SettingsAppWidgetProvider");
                          poke.addCategory(Intent.CATEGORY_ALTERNATIVE);
                          poke.setData(Uri.parse("3"));
                          this.sendBroadcast(poke);
                      }
                  }
                  
                  @Override
                  public void onLocationChanged(Location location) {
                      // TODO Auto-generated method stub
                  
                  }
                  
                  @Override
                  public void onStatusChanged(String provider, int status, Bundle extras) {
                      // TODO Auto-generated method stub
                  
                  }
                  
                  @Override
                  public void onProviderEnabled(String provider) {
                      // TODO Auto-generated method stub
                  
                  }
                  
                  @Override
                  public void onProviderDisabled(String provider) {
                      // TODO Auto-generated method stub
                  
                  }
                  
                  
                  class YourAsyncTaskLogin extends AsyncTask<Void, Void, Void> {
                  
                      //private ProgressDialog _ProgressDialog;
                  
                      @Override
                      protected void onPreExecute() {
                          // show your dialog here
                  
                          /*_ProgressDialog = ProgressDialog.show(getApplicationContext(), "",
                                  "Loading", true);*/
                  
                      }
                  
                      @Override
                      protected Void doInBackground(Void... params) {
                          json = userFunction.sendLocations(android_id, userName,latitude+"", longitude+"");
                          return null;
                      }
                  
                      protected void onPostExecute(Void result) {
                          try {
                              Log.e("Key_Success:",
                                      json.getString(KEY_SUCCESS));
                              if (json.getString(KEY_SUCCESS) != null) {
                                  // loginErrorMsg.setText("");
                                  String res = json.getString(KEY_SUCCESS);
                  
                                  if (Integer.parseInt(res) == 1) {
                  
                  
                  
                                  } else {
                                      // Error in login
                                      // loginErrorMsg.setText("Incorrect username/password");
                  
                                      //_ProgressDialog.cancel();
                  
                  
                                  }
                  
                              } else {
                                  // Error in login
                                  // loginErrorMsg.setText("Incorrect username/password");
                  
                                  //_ProgressDialog.cancel();         
                  
                              }
                          } catch (JSONException e) {
                              e.printStackTrace();
                              Log.e("error", e.getMessage());
                          }
                  
                          //_ProgressDialog.dismiss();
                      }
                  }
                  public String getAccount() {
                      AccountManager manager = (AccountManager) getSystemService(ACCOUNT_SERVICE);
                      Account[] list = manager.getAccountsByType("com.google");
                      if (list.length != 0) {
                          String email = list[0].name;
                          return email;
                      } else {
                          return null;
                      }
                  }
                  }
                  

                  這篇關于如何通過其 android id 獲取 android 設備的位置的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Help calculating X and Y from Latitude and Longitude in iPhone(幫助從 iPhone 中的緯度和經度計算 X 和 Y)
                  Get user#39;s current location using GPS(使用 GPS 獲取用戶的當前位置)
                  IllegalArgumentException thrown by requestLocationUpdate()(requestLocationUpdate() 拋出的 IllegalArgumentException)
                  How reliable is LocationManager#39;s getLastKnownLocation and how often is it updated?(LocationManager 的 getLastKnownLocation 有多可靠,多久更新一次?)
                  CLLocation returning negative speed(CLLocation 返回負速度)
                  How to detect Location Provider ? GPS or Network Provider(如何檢測位置提供者?GPS 或網絡提供商)
                • <tfoot id='e0W3P'></tfoot>
                    <tbody id='e0W3P'></tbody>

                          <legend id='e0W3P'><style id='e0W3P'><dir id='e0W3P'><q id='e0W3P'></q></dir></style></legend>
                        • <small id='e0W3P'></small><noframes id='e0W3P'>

                          <i id='e0W3P'><tr id='e0W3P'><dt id='e0W3P'><q id='e0W3P'><span id='e0W3P'><b id='e0W3P'><form id='e0W3P'><ins id='e0W3P'></ins><ul id='e0W3P'></ul><sub id='e0W3P'></sub></form><legend id='e0W3P'></legend><bdo id='e0W3P'><pre id='e0W3P'><center id='e0W3P'></center></pre></bdo></b><th id='e0W3P'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='e0W3P'><tfoot id='e0W3P'></tfoot><dl id='e0W3P'><fieldset id='e0W3P'></fieldset></dl></div>

                            <bdo id='e0W3P'></bdo><ul id='e0W3P'></ul>

                          • 主站蜘蛛池模板: 亚洲成人国产精品 | 成人三级在线播放 | 欧美一区二区在线 | 日韩成人一区 | 国产欧美精品一区二区三区 | 欧美aaaaa| 国产成人高清视频 | 在线只有精品 | 亚洲精品不卡 | 天天天操天天天干 | 一区二区三区四区在线 | 毛片一区二区三区 | 色视频网站 | 日韩一区在线播放 | 久久久日韩精品一区二区三区 | 91九色在线观看 | 99久久精品免费 | 久久久精品一区 | 亚洲天堂色 | 欧美日本在线观看 | 99久久中文字幕三级久久日本 | 亚洲视频免费在线看 | 国产成人精品在线 | 91精品国产一区二区三区 | av免费网址 | 亚州综合在线 | 久久久久久久久久久福利观看 | 亚洲成人第一页 | 日韩视频一区二区 | 久久久久久久久久久久久九 | 国产精品爱久久久久久久 | 91影片| 久久美女网 | 一级午夜aaa免费看三区 | 粉嫩av | 欧美日韩国产高清视频 | 亚洲一级淫片 | 国产一区二区在线免费观看 | 久久综合成人精品亚洲另类欧美 | 欧美一级免费看 | 精品熟人一区二区三区四区 |