当我启动我的应用程序时,我得到一个“InstantiationException”

时间:2017-10-27 14:27:33

标签: android

当我启动我的应用程序并按下我的应用程序中的“开始”按钮时,我收到错误消息“我的应用程序已停止工作”,然后在监视器中显示此消息“由以下引起:java.lang.InstantiationException:java。 lang.Class无法实例化“

这是代码

package com.example.lars.myapplication;

import android.app.Activity;
import android.app.ProgressDialog;
import android.graphics.PixelFormat;
import android.media.MediaPlayer;
import android.media.session.MediaController;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.VideoView;



public abstract class lydbrett extends AppCompatActivity implements View.OnClickListener {

ProgressDialog mDialog;
    VideoView videoView;
    ImageView btnPlayPause;
    Uri uri;

    String videoURL ="http://techslides.com/demos/sample-videos/small.mp4";





    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_lydbrett);

        videoView = (VideoView) findViewById(R.id.videoView2);
        btnPlayPause = (ImageButton) findViewById(R.id.imageButton);
        btnPlayPause.setOnClickListener(this);

    }
        @Override
        public void onClick(View v){
            mDialog = new ProgressDialog(lydbrett.this);
            mDialog.setMessage("Vent litt...");
            mDialog.setCanceledOnTouchOutside(false);
            mDialog.show();

            try {
                if (!videoView.isPlaying()) {
                    Uri uri = Uri.parse(videoURL);
                }
                videoView.setVideoURI(uri);
                videoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
                    @Override
                    public void onCompletion(MediaPlayer mp) {
                    }
                });


            }
            catch (Exception ex){
        }
            videoView.requestFocus();
        videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener(){
            @Override
            public void onPrepared(MediaPlayer mp) {
                mDialog.dismiss();
                mp.setLooping(true);
                videoView.start();
            }




        });
}}

1 个答案:

答案 0 :(得分:0)

从lydbrett类(活动)中删除abstract关键字