Java Code Examples for com.mapbox.mapboxsdk.Mapbox#getInstance()

The following examples show how to use com.mapbox.mapboxsdk.Mapbox#getInstance() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TabbedMainActivity.java    From ShapeOfView with Apache License 2.0 8 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.shape_of_view_tabbed_activity_main);
    ButterKnife.bind(this);
    Mapbox.getInstance(this, "pk.eyJ1IjoiY2hpY2tpbm5pY2siLCJhIjoiY2pka3U2YTdiMDE1YTJ4cjA0YzVyYnpoMSJ9.xlyPakmrR_N4bNqIGe6AKg");
    viewPager.setAdapter(new FakeAdapter(getSupportFragmentManager()));

    tabLayout.setupWithViewPager(viewPager);

    TabIndicatorFollower.setupWith(tabLayout, triangle);
    mapView = (MapView) findViewById(R.id.mapView);
    mapView.onCreate(savedInstanceState);

    RxLifecycle.with(this).onResume().subscribe(event -> mapView.onResume());
    RxLifecycle.with(this).onPause().subscribe(event -> mapView.onPause());
    RxLifecycle.with(this).onStop().subscribe(event -> mapView.onStop());
    RxLifecycle.with(this).onDestroy().subscribe(event -> mapView.onDestroy());
}
 
Example 2
Source File: NavigationApplication.java    From graphhopper-navigation-android with MIT License 8 votes vote down vote up
@Override
public void onCreate() {
  super.onCreate();

  // Leak canary
  if (LeakCanary.isInAnalyzerProcess(this)) {
    return;
  }
  LeakCanary.install(this);

  if (BuildConfig.DEBUG) {
    Timber.plant(new Timber.DebugTree());
  }

  // Set access token
  String mapboxAccessToken = Utils.getMapboxAccessToken(getApplicationContext());
  if (TextUtils.isEmpty(mapboxAccessToken) || mapboxAccessToken.equals(DEFAULT_MAPBOX_ACCESS_TOKEN)) {
    Log.w(LOG_TAG, "Warning: access token isn't set.");
  }

  Mapbox.getInstance(getApplicationContext(), mapboxAccessToken);
}
 
Example 3
Source File: App.java    From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    Timber.plant(BuildConfig.DEBUG ? new DebugTree() : new ReleaseTree());
    ProcessLifecycleOwner.get().getLifecycle().addObserver(this);

    if (BuildConfig.DEBUG)
        Stetho.initializeWithDefaults(this);

    Mapbox.getInstance(this, BuildConfig.MAPBOX_ACCESS_TOKEN);

    Fabric.with(this, new Crashlytics());

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
        upgradeSecurityProviderSync();

    setUpAppComponent();
    setUpServerComponent();
    setUpRxPlugin();
}
 
Example 4
Source File: NavigationLauncherActivity.java    From graphhopper-navigation-example with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_navigation_launcher);
    Mapbox.getInstance(this.getApplicationContext(), getString(R.string.mapbox_access_token));
    Telemetry.disableOnUserRequest();
    ButterKnife.bind(this);
    mapView.setStyleUrl(getString(R.string.map_view_styleUrl));
    mapView.onCreate(savedInstanceState);
    mapView.getMapAsync(this);
    localeUtils = new LocaleUtils();
    if (getSupportActionBar() != null) {
        getSupportActionBar().setTitle("");
    }
    showFirstStartIfNecessary();
}
 
Example 5
Source File: MapActivity.java    From deltachat-android with GNU General Public License v3.0 6 votes vote down vote up
public static void lazyMapboxInit(Context context) {
    try {
        Mapbox.getInstance(context, BuildConfig.MAP_ACCESS_TOKEN);

        // disable telemetry. these functions are currently partly redundant,
        // however, implementations may change
        // and the two explicit calls seems to have worked in the past,
        // see https://github.com/mapbox/mapbox-gl-native/issues/13304
        TelemetryEnabler.updateTelemetryState(TelemetryEnabler.State.DISABLED);
        TelemetryDefinition telemetry = Mapbox.getTelemetry();
        if (telemetry != null) {
            telemetry.setUserTelemetryRequestState(false);
        }
    }
    catch(Exception e) {
        e.printStackTrace();
    }
}
 
Example 6
Source File: MapwizeFragment.java    From mapwize-ui-android with MIT License 4 votes vote down vote up
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Mapbox.getInstance(container.getContext(), "pk.mapwize");
    return inflater.inflate(R.layout.mapwize_fragment, container, false);
}