Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
  Jacob Le
3,785 PointsI'm getting a AUDIO_OUTPUT_FLAG_FAST denied by client error whenever I tap on the Hourly Forecast button (Stormy)
The app runs with the current forecast screen and 7 day forecast screen, but whenever I tap the hourly forecast button, I get a AUDIO_OUTPUT_FLAG_FAST denied by client log in logcat. Other than that, nothing happens. I am using a Genymotion Nexus 5 emulator.
package com.example.gaming.stormy.weather;
import android.os.Parcel;
import android.os.Parcelable;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
 * Created by Gaming on 7/30/2015.
 */
public class Hour implements Parcelable {
    private long mTime;
    private String mSummary;
    private double mTemperature;
    private String mIcon;
    private String mTimezone;
    public Hour(){}
    private Hour(Parcel in) {
        mTime = in.readLong();
        mTemperature = in.readDouble();
        mSummary = in.readString();
        mIcon = in.readString();
        mTimezone = in.readString();
    }
    public long getTime() {
        return mTime;
    }
    public void setTime(long time) {
        mTime = time;
    }
    public String getSummary() {
        return mSummary;
    }
    public void setSummary(String summary) {
        mSummary = summary;
    }
    public int getTemperature() {
        return (int) Math.round(mTemperature);
    }
    public void setTemperature(double temperature) {
        mTemperature = temperature;
    }
    public String getIcon() {
        return mIcon;
    }
    public void setIcon(String icon) {
        mIcon = icon;
    }
    public int getIconId(){
        return Forecast.getIconId(mIcon);
    }
    public String getTimezone() {
        return mTimezone;
    }
    public void setTimezone(String timezone) {
        mTimezone = timezone;
    }
    public String getHour(){
        SimpleDateFormat formatter = new SimpleDateFormat("h a");
        Date date = new Date(mTime *1000);
        return formatter.format(date);
    }
    @Override
    public int describeContents() {
        return 0;
    }
    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeLong(mTime);
        dest.writeDouble(mTemperature);
        dest.writeString(mSummary);
        dest.writeString(mIcon);
        dest.writeString(mTimezone);
    }
    public static final Creator<Hour> CREATOR = new Creator<Hour>() {
        @Override
        public Hour createFromParcel(Parcel source) {
            return new Hour(source);
        }
        @Override
        public Hour[] newArray(int size) {
            return new Hour[size];
        }
    };
}
package com.example.gaming.stormy.adapters;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.example.gaming.stormy.R;
import com.example.gaming.stormy.weather.Hour;
/**
 * Created by Gaming on 8/1/2015.
 */
public class HourAdapter extends RecyclerView.Adapter<HourAdapter.HourViewHolder> {
//Recycler View is about the same as a ListView adapter, only both the views and data mapping are
    //both inside
    private Hour[] mHours;
    public HourAdapter(Hour[] hours){
        mHours = hours;
    }
    @Override
    public HourViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext())
                .inflate(R.layout.hourly_list_item, parent, false);
        HourViewHolder viewHolder = new HourViewHolder(view);
        return viewHolder;
    }
    @Override
    public void onBindViewHolder(HourViewHolder holder, int position) {
        holder.bindHour(mHours[position]);
    }
    @Override
    public int getItemCount() {
        return mHours.length;
    }
    public class HourViewHolder extends RecyclerView.ViewHolder{
        public TextView mTimeLabel;
        public TextView mSummaryLabel;
        public TextView mTemperatureLabel;
        public ImageView mIconImageView;
        public HourViewHolder(View itemView) {
            super(itemView);
            mTimeLabel = (TextView) itemView.findViewById(R.id.timeLabel);
            mSummaryLabel = (TextView) itemView.findViewById(R.id.summaryLabel);
            mTemperatureLabel = (TextView) itemView.findViewById(R.id.summaryLabel);
            mIconImageView = (ImageView) itemView.findViewById(R.id.iconImageView);
        }
        public void bindHour(Hour hour)
        {
            mTimeLabel.setText(hour.getHour());
            mSummaryLabel.setText(hour.getSummary());
            mTemperatureLabel.setText(hour.getTemperature() + "");
            mIconImageView.setImageResource(hour.getIconId());
        }
    }
}
package com.example.gaming.stormy.UI;
import android.app.Activity;
import android.content.Intent;
import android.os.Parcelable;
import android.support.annotation.Nullable;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.Menu;
import android.view.MenuItem;
import com.example.gaming.stormy.R;
import com.example.gaming.stormy.adapters.HourAdapter;
import com.example.gaming.stormy.weather.Hour;
import java.util.Arrays;
import butterknife.Bind;
import butterknife.ButterKnife;
public class HourlyForecastActivity extends Activity {
    private Hour[] mHours;
    @Nullable @Bind(R.id.recyclerView) RecyclerView mRecyclerView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_hourly_forecast);
        ButterKnife.bind(this);
        Intent intent = getIntent();
        Parcelable[] parcelables = intent.getParcelableArrayExtra(MainActivity.HOURLY_FORECAST);
        mHours = Arrays.copyOf(parcelables, parcelables.length, Hour[].class);
        HourAdapter adapter = new HourAdapter(mHours);
        mRecyclerView.setAdapter(adapter);
        RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(this);
        mRecyclerView.setLayoutManager(layoutManager);
        mRecyclerView.setHasFixedSize(true);
    }
}
1 Answer
Harry James
14,780 PointsHey Jacob!
That's a strange error - it means there's something to do with the sound (Of which is not used in this project).
From the code you've provided, it looks like you don't have an OnClickListener() set up so I'm assuming you get this error when tapping on the button which does nothing right now.
In which case, I guess this error is being caused by the Android system itself, rather than your app. I guess this is something to do with Genymotion's emulator using the wrong sample rate - when you tap on a button in Android, it makes a "tap" noise, this noise seems to be causing the error that's appearing in Logcat.
This should not affect your project in any way and if you were to test it on an actual device, there would be no effect on the user.
Hope it helps and if you have any more questions, let me know and I'll try my best to help :)