Created
December 7, 2017 13:10
-
-
Save 1fabiopereira/2a362193c32c7eb2c60bcf361bf12637 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Class SettingsModule | |
* | |
* @copyright (c) Climatempo 2017 | |
* | |
* @version 1.0.0 | |
* @author Fábio Pereira <[email protected]> | |
* | |
*/ | |
package com.climatempolite.settings; | |
import android.content.Context; | |
import android.content.Intent; | |
import android.provider.Settings; | |
import com.facebook.react.bridge.ReactApplicationContext; | |
import com.facebook.react.bridge.ReactContextBaseJavaModule; | |
import com.facebook.react.bridge.ReactMethod; | |
public class SettingsModule extends ReactContextBaseJavaModule { | |
/** | |
* Contexto da aplicação | |
* */ | |
private Context context; | |
/** | |
* Nome do modulo | |
* */ | |
private final static String NAME = "SettingsModule"; | |
public SettingsModule(ReactApplicationContext reactContext) { | |
super(reactContext); | |
context = reactContext; | |
} | |
/** | |
* Retorna o nome do modulo | |
* */ | |
@Override | |
public String getName() { | |
return NAME; | |
} | |
/** | |
* Abre as configurações de Wifi | |
* */ | |
@ReactMethod | |
public void openWifiSettings () { | |
Intent intent = new Intent(Settings.ACTION_WIFI_SETTINGS); | |
if (intent.resolveActivity(this.getReactApplicationContext().getPackageManager()) != null) { | |
this.context.startActivity(intent); | |
} | |
} | |
/** | |
* Abre as configurações de Localização | |
* */ | |
@ReactMethod | |
public void openLocationSettings () { | |
Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); | |
if (intent.resolveActivity(this.getReactApplicationContext().getPackageManager()) != null) { | |
this.getReactApplicationContext().startActivity(intent); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment