1
我有一个活动(活动A),可以调用另一个从URL(视频视频)加载视频的活动。当我回到活动A,我可以去活动B,我有一个代码执行与HttpURLConnection的请求。问题是如果我去活动视频并加载Videoview,请求活动B返回一个空响应。Android - Videoview URL HttpURLConnection
如果我更改活动视频并删除视频视图,它工作良好。
活动视频:
String urlVideo = getIntent().getStringExtra("URL_TRAILER");
Uri uri = Uri.parse(urlVideo);
videoView = (VideoView)findViewById(R.id.myvideoview);
MediaController mc = new MediaController(this);
mc.setAnchorView(videoView);
mc.setMediaPlayer(videoView);
videoView.setMediaController(mc);
videoView.setVideoURI(uri);
videoView.start();
HttpURLConnection的
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setDefaultUseCaches(false);
conn.setUseCaches(false);
conn.setReadTimeout(15000);
conn.setConnectTimeout(15000);
conn.setRequestMethod("POST");
conn.setDoInput(true);
conn.setDoOutput(true);
int responseCode = conn.getResponseCode();
if (responseCode == HttpsURLConnection.HTTP_OK) {
String line;
BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
while ((line = br.readLine()) != null) {
response += line;
}
} else {
response = "";
}