title: Permission denied (missing INTERNET permission?) when using exoplayer
body: <p>I am beginner in android i try to use ExoPlayer to show video but i have a problem when trying to run the elumater it crashes and give me that error in the logcat "Unexpected exception loading stream "</p>
  
  <p><strong>This is my Logcat error</strong></p>
  
  
  
  <pre class="lang-html prettyprint-override"><code>10-17 17:31:12.619 8321-8631/com.example.abdelmagied.bakingapp E/LoadTask: Unexpected exception loading stream
    java.lang.SecurityException: Permission denied (missing INTERNET permission?)
       at java.net.InetAddress.lookupHostByName(InetAddress.java:464)
       at java.net.InetAddress.getAllByNameImpl(InetAddress.java:252)
       at java.net.InetAddress.getAllByName(InetAddress.java:215)
       at com.android.okhttp.internal.Network$1.resolveInetAddresses(Network.java:29)
       at com.android.okhttp.internal.http.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:188)
       at com.android.okhttp.internal.http.RouteSelector.nextProxy(RouteSelector.java:157)
       at com.android.okhttp.internal.http.RouteSelector.next(RouteSelector.java:100)
       at com.android.okhttp.internal.http.HttpEngine.createNextConnection(HttpEngine.java:357)
       at com.android.okhttp.internal.http.HttpEngine.nextConnection(HttpEngine.java:340)
       at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:330)
       at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:248)
       at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:433)
       at com.android.okhttp.internal.huc.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:114)
       at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.connect(DelegatingHttpsURLConnection.java:89)
       at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java)
       at com.google.android.exoplayer2.upstream.DefaultHttpDataSource.makeConnection(DefaultHttpDataSource.java:427)
       at com.google.android.exoplayer2.upstream.DefaultHttpDataSource.makeConnection(DefaultHttpDataSource.java:351)
       at com.google.android.exoplayer2.upstream.DefaultHttpDataSource.open(DefaultHttpDataSource.java:193)
       at com.google.android.exoplayer2.upstream.DefaultDataSource.open(DefaultDataSource.java:123)
       at com.google.android.exoplayer2.source.ExtractorMediaPeriod$ExtractingLoadable.load(ExtractorMediaPeriod.java:623)
       at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:295)
       at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423)
       at java.util.concurrent.FutureTask.run(FutureTask.java:237)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
       at java.lang.Thread.run(Thread.java:818)
    Caused by: android.system.GaiException: android_getaddrinfo failed: EAI_NODATA (No address associated with hostname)
       at libcore.io.Posix.android_getaddrinfo(Native Method)
       at libcore.io.ForwardingOs.android_getaddrinfo(ForwardingOs.java:55)
  </code></pre>
  
  <p><strong>This is my manifest file</strong></p>
  
  
  
  <pre class="lang-html prettyprint-override"><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.example.abdelmagied.bakingapp"&gt;
      &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
      &lt;application
          android:allowBackup="true"
          android:icon="@mipmap/ic_launcher"
          android:label="@string/app_name"
          android:roundIcon="@mipmap/ic_launcher_round"
          android:supportsRtl="true"
          android:theme="@style/AppTheme"&gt;
          &lt;activity android:name=".MainActivity"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
  
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
          &lt;activity android:name=".recipeDetailsActivity" /&gt;
          &lt;activity android:name=".recipeFragment" /&gt;
          &lt;activity android:name=".stepDetailActivity"&gt;&lt;/activity&gt;
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p><strong>Activity containing Exoplayer</strong></p>
  
  
  
  <pre class="lang-html prettyprint-override"><code>package com.example.abdelmagied.bakingapp;
  
  import android.app.NotificationManager;
  import android.net.Uri;
  import android.os.Handler;
  import android.support.v4.media.session.MediaSessionCompat;
  import android.support.v4.media.session.PlaybackStateCompat;
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.widget.TextView;
  import android.widget.Toast;
  
  import com.example.abdelmagied.bakingapp.recipeContents.steps;
  import com.google.android.exoplayer2.DefaultLoadControl;
  import com.google.android.exoplayer2.ExoPlaybackException;
  import com.google.android.exoplayer2.ExoPlayer;
  import com.google.android.exoplayer2.ExoPlayerFactory;
  import com.google.android.exoplayer2.LoadControl;
  import com.google.android.exoplayer2.SimpleExoPlayer;
  import com.google.android.exoplayer2.Timeline;
  import com.google.android.exoplayer2.extractor.DefaultExtractorsFactory;
  import com.google.android.exoplayer2.source.ExtractorMediaSource;
  import com.google.android.exoplayer2.source.MediaSource;
  import com.google.android.exoplayer2.source.TrackGroupArray;
  import com.google.android.exoplayer2.trackselection.AdaptiveVideoTrackSelection;
  import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
  import com.google.android.exoplayer2.trackselection.TrackSelection;
  import com.google.android.exoplayer2.trackselection.TrackSelectionArray;
  import com.google.android.exoplayer2.trackselection.TrackSelector;
  import com.google.android.exoplayer2.ui.SimpleExoPlayerView;
  import com.google.android.exoplayer2.upstream.BandwidthMeter;
  import com.google.android.exoplayer2.upstream.DefaultBandwidthMeter;
  import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory;
  import com.google.android.exoplayer2.util.Util;
  
  import butterknife.BindView;
  import butterknife.ButterKnife;
  
  public class stepDetailActivity extends AppCompatActivity implements  ExoPlayer.EventListener {
      private SimpleExoPlayer mExoPlayer;
      private SimpleExoPlayerView mPlayerView;
      private static MediaSessionCompat mMediaSession;
      private PlaybackStateCompat.Builder mStateBuilder;
      @BindView(R.id.description)
      public TextView descrip;
      private static final String TAG = stepDetailActivity.class.getSimpleName();
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_step_detail);
  
          steps myrecipes = (steps) getIntent().getParcelableExtra("stepDetails");
  
          mPlayerView = (SimpleExoPlayerView) findViewById(R.id.player);
          initializeMediaSession();
          initializePlayer(Uri.parse("https://d17h27t6h515a5.cloudfront.net/topher/2017/April/58ffd9cb_4-press-crumbs-in-pie-plate-creampie/4-press-crumbs-in-pie-plate-creampie.mp4"));
          descrip.setText(myrecipes.getDescription());
  
      }
      private void initializePlayer(Uri mediaUri) {
          if (mExoPlayer == null) {
             // Create an instance of the ExoPlayer.
             TrackSelector trackSelector = new DefaultTrackSelector();
              LoadControl loadControl = new DefaultLoadControl();
              mExoPlayer = ExoPlayerFactory.newSimpleInstance(this, trackSelector, loadControl);
              mPlayerView.setPlayer(mExoPlayer);
  
              // Prepare the MediaSource.
              String userAgent = Util.getUserAgent(this, "Bakingapp");
              MediaSource mediaSource = new ExtractorMediaSource(mediaUri, new DefaultDataSourceFactory(
                      this, userAgent), new DefaultExtractorsFactory(), null, null);
              mExoPlayer.prepare(mediaSource);
              mExoPlayer.setPlayWhenReady(true);
              // Set the ExoPlayer.EventListener to this activity.
              mExoPlayer.addListener(this);
          }
      }
  
      /**
       * Initializes the Media Session to be enabled with media buttons, transport controls, callbacks
       * and media controller.
       */
      private void initializeMediaSession() {
  
          // Create a MediaSessionCompat.
          mMediaSession = new MediaSessionCompat(this, TAG);
  
          // Enable callbacks from MediaButtons and TransportControls.
          mMediaSession.setFlags(
                  MediaSessionCompat.FLAG_HANDLES_MEDIA_BUTTONS |
                          MediaSessionCompat.FLAG_HANDLES_TRANSPORT_CONTROLS);
  
          // Do not let MediaButtons restart the player when the app is not visible.
          mMediaSession.setMediaButtonReceiver(null);
  
          // Set an initial PlaybackState with ACTION_PLAY, so media buttons can start the player.
          mStateBuilder = new PlaybackStateCompat.Builder()
                  .setActions(
                          PlaybackStateCompat.ACTION_PLAY |
                                  PlaybackStateCompat.ACTION_PAUSE |
                                  PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS |
                                  PlaybackStateCompat.ACTION_PLAY_PAUSE);
  
          mMediaSession.setPlaybackState(mStateBuilder.build());
  
  
          // MySessionCallback has methods that handle callbacks from a media controller.
          mMediaSession.setCallback(new MySessionCallback());
  
          // Start the Media Session since the activity is active.
          mMediaSession.setActive(true);
  
      }
  
      @Override
      public void onTimelineChanged(Timeline timeline, Object manifest) {
  
      }
  
      @Override
      public void onTracksChanged(TrackGroupArray trackGroups, TrackSelectionArray trackSelections) {
  
      }
  
      @Override
      public void onLoadingChanged(boolean isLoading) {
  
      }
  
      @Override
      public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
          if((playbackState == ExoPlayer.STATE_READY) &amp;&amp; playWhenReady){
              mStateBuilder.setState(PlaybackStateCompat.STATE_PLAYING,
                      mExoPlayer.getCurrentPosition(), 1f);
          } else if((playbackState == ExoPlayer.STATE_READY)){
              mStateBuilder.setState(PlaybackStateCompat.STATE_PAUSED,
                      mExoPlayer.getCurrentPosition(), 1f);
          }
          mMediaSession.setPlaybackState(mStateBuilder.build());
      }
  
      @Override
      public void onPlayerError(ExoPlaybackException error) {
  
      }
  
      @Override
      public void onPositionDiscontinuity() {
  
      }
  
      /**
       * Media Session Callbacks, where all external clients control the player.
       */
      private class MySessionCallback extends MediaSessionCompat.Callback {
          @Override
          public void onPlay() {
              mExoPlayer.setPlayWhenReady(true);
          }
  
          @Override
          public void onPause() {
              mExoPlayer.setPlayWhenReady(false);
          }
  
          @Override
          public void onSkipToPrevious() {
              mExoPlayer.seekTo(0);
          }
      }
  }
  </code></pre>
  
  <p><strong>This is my XML layout</strong></p>
  
  
  
  <pre class="lang-html prettyprint-override"><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      tools:context="com.example.abdelmagied.bakingapp.stepDetailActivity"&gt;
  &lt;LinearLayout
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical"&gt;
      &lt;com.google.android.exoplayer2.ui.SimpleExoPlayerView
          android:id="@+id/player"
          android:layout_width="match_parent"
          android:layout_height="300dp"
          &gt;
      &lt;/com.google.android.exoplayer2.ui.SimpleExoPlayerView&gt;
  
      &lt;ScrollView
          android:layout_marginTop="20dp"
          android:layout_width="match_parent"
          android:layout_height="match_parent"&gt;
            &lt;TextView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:id = "@+id/description"
                android:text = "som mu"
                android:textSize = "20dp"
                /&gt;
  
      &lt;/ScrollView&gt;
  &lt;/LinearLayout&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>