I get error this (in logcat), and my emulator shows: Unfortunately, this app has stopped. I just want to animated GIFs in Android.
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.nasimjon.nasimjon/com.example.nasimjon.nasimjon.MainActivity}: java.lang.NullPointerException
This my 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();
}
}
public class MainActivity extends Activity {
private class MyWebViewClient extends WebViewClient{ @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; }
}