SORU
9 Mayıs 2009, CUMARTESİ


Nasıl eğer Android bir cihazın GPS etkinse öğrenebilirim

Android Cupake (1.5) etkin bir aygıtta, nasıl ve GPS kontrol etkinleştirebilirim?

CEVAP
9 Mayıs 2009, CUMARTESİ


En iyi yolu, aşağıdaki gibi görünüyor:

 final LocationManager manager = (LocationManager) getSystemService( Context.LOCATION_SERVICE );

    if ( !manager.isProviderEnabled( LocationManager.GPS_PROVIDER ) ) {
        buildAlertMessageNoGps();
    }

  private void buildAlertMessageNoGps() {
    final AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setMessage("Your GPS seems to be disabled, do you want to enable it?")
           .setCancelable(false)
           .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
               public void onClick(@SuppressWarnings("unused") final DialogInterface dialog, @SuppressWarnings("unused") final int id) {
                   startActivity(new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS));
               }
           })
           .setNegativeButton("No", new DialogInterface.OnClickListener() {
               public void onClick(final DialogInterface dialog, @SuppressWarnings("unused") final int id) {
                    dialog.cancel();
               }
           });
    final AlertDialog alert = builder.create();
    alert.show();
}

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • GavinMichaelBooth

    GavinMichael

    26 AĞUSTOS 2006
  • hoorahjencar

    hoorahjencar

    6 HAZİRAN 2007
  • Justin Davis

    Justin Davis

    14 Ocak 2008