Skip to content

Instantly share code, notes, and snippets.

@1fabiopereira
Created December 7, 2017 13:10
Show Gist options
  • Save 1fabiopereira/2a362193c32c7eb2c60bcf361bf12637 to your computer and use it in GitHub Desktop.
Save 1fabiopereira/2a362193c32c7eb2c60bcf361bf12637 to your computer and use it in GitHub Desktop.
/**
* 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