SurficeView回调 - 未调用

时间:2013-02-18 14:05:36

标签: android surfaceview surfaceholder

我正在处理我的第一个原生应用。我不确定为什么没有创建这些回调,或者至少是surfaceCreated回调?

public class MainActivity extends Activity implements OnCompletionListener, SurfaceHolder.Callback {

private static final String TAG = "MainActivity";
VideoView videoView;
private SurfaceHolder holder;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    SurfaceView surface = (SurfaceView) findViewById(R.id.surface);
    holder = surface.getHolder();
    holder.addCallback(this);
    new AlertDialog.Builder(this).setTitle("Argh").setMessage("Started activity!").setNeutralButton("Close", null).show();
    // This alert works, nothing else
}



@Override
public void surfaceCreated(SurfaceHolder holder) {
    new AlertDialog.Builder(this).setTitle("Argh").setMessage("Surface created!").setNeutralButton("Close", null).show();
}

@Override
public void onCompletion(MediaPlayer arg0) {
    new AlertDialog.Builder(this).setTitle("Argh").setMessage("onCompletion!").setNeutralButton("Close", null).show();
}

@Override
public void surfaceChanged(SurfaceHolder arg0, int arg1, int arg2, int arg3) {
    new AlertDialog.Builder(this).setTitle("Argh").setMessage("surfaceChanged!").setNeutralButton("Close", null).show();

}

@Override
public void surfaceDestroyed(SurfaceHolder arg0) {
    new AlertDialog.Builder(this).setTitle("Argh").setMessage("surfaceDestroyed!").setNeutralButton("Close", null).show();

}
}

0 个答案:

没有答案