我是android开发的新手,我开发了一个应用程序,可以下载,保存然后在videoview中播放视频。该应用程序只能在某些手机上使用,而不能在其他手机上使用。该应用程序图标也将不适用于这些型号。我已经看过代码,但是没有运气。
我尝试在4个不同的手机上安装该应用程序,并且可以在其中2个手机上运行,但我无法弄清楚出了什么问题
class DownloadVideoFromURL extends AsyncTask<String, String, String> {
DownloadVideoFromURL() {
}
protected void onPreExecute() {
super.onPreExecute();
VidDetailFragment.this.pDialog.show();
}
protected String doInBackground(String... vidFilename) {
try {
URL url = new URL(VidDetailFragment.this.getVidUrl(vidFilename[0]));
URLConnection connection = url.openConnection();
connection.connect();
int lengthOfFile = connection.getContentLength();
InputStream input = new BufferedInputStream(url.openStream(), 8192);
OutputStream output = new FileOutputStream(VidDetailFragment.this.getVidPath(vidFilename[0]));
byte[] data = new byte[1024];
long total = 0;
while (true) {
int count = input.read(data);
if (count == -1) {
break;
}
total += (long) count;
publishProgress(new String[]{"" + ((int) ((100 * total) / ((long) lengthOfFile)))});
output.write(data, 0, count);
}
output.flush();
output.close();
input.close();
} catch (FileNotFoundException e) {
Log.e("Deafop Error:.", e.getMessage());
} catch (Exception e2) {
Log.e("Deafop Error: ", e2.getMessage());
}
return vidFilename[0];
}
protected void onProgressUpdate(String... progress) {
VidDetailFragment.this.pDialog.setProgress(Integer.parseInt(progress[0]));
}
protected void onPostExecute(String vidFilename) {
VidDetailFragment.this.pDialog.dismiss();
VidDetailFragment.this.playVideo(vidFilename);
}
}
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getArguments().containsKey(ARG_ITEM_ID)) {
Log.e("Deafop", "Loading Video: " + getArguments().getString(ARG_ITEM_ID));
this.mItem = (Vid) VidClass.ITEM_MAP.get(getArguments().getString(ARG_ITEM_ID));
}
}
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_vid_detail, container, false);
this.mVideoView = (VideoView) rootView.findViewById(R.id.videoview);
if (this.mItem != null) {
String vidFilename = this.mItem.video + ".mp4";
Log.d("Deafop", "Video File " + vidFilename);
if (new File(getVidPath(vidFilename)).exists()) {
playVideo(vidFilename);
} else {
Log.d("Deafop", "Sorry, video file missing, attempting download from: " + getVidUrl(vidFilename));
this.pDialog = ProgressDialog.show(getActivity(), "Please wait", "Downloading Video...", false, true);
this.pDialog.setMax(100);
this.pDialog.setProgressStyle(1);
new DownloadVideoFromURL().execute(new String[]{vidFilename});
}
((TextView) rootView.findViewById(R.id.vid_detail)).setText(this.mItem.word + ": " + this.mItem.description + " " + this.mItem.memoryaid);
this.mVideoView.setOnTouchListener(new C01351());
}