title: Error my first gif image app on android studio
body: <p>I get error this (in logcat), and my emulator shows: Unfortunately, this app has stopped. I just want to animated GIFs in Android.</p>
  
  <pre><code>java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.nasimjon.nasimjon/com.example.nasimjon.nasimjon.MainActivity}: java.lang.NullPointerException
  </code></pre>
  
  <p>This my Code:</p>
  
  <pre><code>public class GifView  extends View {
  
  private Movie mMovie;
  InputStream mStream;
  long mMoviestart;
  
  
  public GifView(Context context, InputStream stream) {
      super(context);
      mStream = stream;
      mMovie = Movie.decodeStream(mStream);
  }
  
  @Override
  protected void onDraw(Canvas canvas){
      canvas.drawColor(Color.TRANSPARENT);
      super.onDraw(canvas);
      final long now = SystemClock.uptimeMillis();
  
      if (mMoviestart == 0){
          mMoviestart = now;
      }
      final int relTime = (int) ((now - mMoviestart)% mMovie.duration());
      mMovie.setTime(relTime);
      mMovie.draw(canvas, 10, 10);
      this.invalidate();
  }
  </code></pre>
  
  <p>}</p>