Skip to content Skip to sidebar Skip to footer

Unable To Execute Activity In Android For Weatherlib

I have following code to use weatherlib to get weather condition in android using android studio. My activity: import android.app.Activity; import android.content.Context; im

Solution 1:

client.updateWeatherConfig(config); must be called after initializing provider as:

    WeatherClient client = WeatherClientDefault.getInstance();
    client.init(ctx);

    WeatherConfig config = new WeatherConfig();
    config.unitSystem = WeatherConfig.UNIT_SYSTEM.M;
    config.lang = "en"; // If you want to use english
    config.maxResult = 5; // Max number of cities retrieved
    config.numDays = 6; // Max num of days in the forecast


    IWeatherProvider provider = null;
    try {
        //provider = WeatherProviderFactory.createProvider(new YahooProviderType(), config);
        provider = WeatherProviderFactory.createProvider(new OpenweathermapProviderType(), config);
        //provider = WeatherProviderFactory.createProvider(new WeatherUndergroundProviderType(), config);
        client.setProvider(provider);

    }
    catch (Throwable t) {
        // There's a problem
    }

    client.updateWeatherConfig(config);

Solution 2:

I guess you didn't import the project correctly or you didnt the right permission to the project.


Post a Comment for "Unable To Execute Activity In Android For Weatherlib"