저는 Android 개발자와 장난을하기 시작했으며 어딘가에 웹에있는 비디오 파일을 재생하려고합니다. 내 main.xml에는 다음과 같습니다VideoView를 사용하려고 할 때 응용 프로그램이 손상되는 경우
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<Button android:layout_height="wrap_content" android:id="@+id/button1" android:layout_width="wrap_content" android:text="@string/buttonText" android:onClick="clickHandler"></Button>
<VideoView android:layout_height="wrap_content" android:layout_width="match_parent" android:id="@+id/MyVideoView"></VideoView>
</LinearLayout>
내 자바 파일은 다음과 같다 : 패키지 com.dop.videoTest; 내가 버튼을 클릭하면
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.MediaController;
import android.widget.Toast;
import android.widget.VideoView;
public class VideoTest extends Activity {
private String path = "http://commonsware.com/misc/test2.3gp";
private VideoView mVideoView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
public void clickHandler(View view)
{
mVideoView = (VideoView) findViewById(R.id.MyVideoView);
if (path == "") {
Toast.makeText(
VideoTest.this,
"Please edit VideoViewDemo Activity, and set path"
+ " variable to your media file URL/path",
Toast.LENGTH_LONG).show();
} else {
mVideoView.setVideoPath(path);
mVideoView.setMediaController(new MediaController(this));
mVideoView.requestFocus();
}
}
}
그래서, 그냥 "응용 프로그램 비디오 테스트가 예기치 않게 중지되었습니다. 다시 시도하십시오."라고
어떤 아이디어가 있습니까?
문자열은 등호 ('path.equals를 ("") ')를 사용하여 비교하려면,하지'경로 ==를
인터넷 권한
는 다음과 같이 설정할 수 있습니다 ""' – MByDlogcat 로그를 추가하십시오. – MByD
== 제대로 작동합니다. 그 외에도 문제가 해결되지 않을 것입니다. – Ronnie