mardi 26 mai 2015

How turn on GPS programmatically in my android application?

If we use this code we see a message: searching for GPS. However, the GPS symbol is merely shown; GPS doesn't actually work:

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Intent intent = new Intent("android.location.GPS_ENABLED_CHANGE");
    intent.putExtra("enabled", true);
    this.sendBroadcast(intent);   
}

Why isn't it working ? And how to make it work correctly ?

Aucun commentaire:

Enregistrer un commentaire