以下是我的源代码。当我尝试在我的 android 模拟器 3.0 上播放这些视频时,我有一些 youtube 视频 ID,一些视频在正确加载后运行良好。但有些视频需要更多时间,最后应用程序被强制关闭。我在这里给了两个 youtube id
- Ju2Krqv9aDU(运行良好)
- IqZf2pj4oj8(进度对话框需要更多时间,最后强制关闭)
我在这里发布了源代码和错误日志。
主布局.java
package com.redorange.motutv;
import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentTransaction;
import android.app.ProgressDialog;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
import com.redorange.blanklayout_for_initialview.InitialTempFragmentPage;
import com.redorange.dramas.ListOfCategoriesDrama;
import com.redorange.livetv.ListOfCountry;
import com.redorange.motutvstaticdata.MotuTVFunctions;
import com.redorange.motutvstaticdata.MotuTVStaticData;
import com.redorange.movies.ListOfCategoriesMovie;
public class MainLayout extends Activity {
TextView tvSelectedOptionName;
TextView tvDate;
TextView tvUserName;
Fragment leftLayout;
Fragment rightLayout;
ProgressDialog progressDialog;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
tvDate = (TextView) findViewById(R.id.tvDate);
tvDate.setText(MotuTVFunctions.getCurrentDate());
tvUserName = (TextView) findViewById(R.id.tvUserName);
tvUserName.setText("Hi " + MotuTVStaticData.save_username);
if (MotuTVStaticData.save_selectedOptionName.equals("Live TV")) {
leftLayout = new ListOfCountry();
// rightLayout = new GridViewWeb1();
rightLayout = new InitialTempFragmentPage();
} else if (MotuTVStaticData.save_selectedOptionName.equals("Movie")) {
leftLayout = new ListOfCategoriesMovie();
// rightLayout = new GridViewWebMovie();
rightLayout = new InitialTempFragmentPage();
} else if (MotuTVStaticData.save_selectedOptionName.equals("Drama")) {
leftLayout = new ListOfCategoriesDrama();
// rightLayout = new GridViewWebDrama();
rightLayout = new InitialTempFragmentPage();
}
new BackgrndProcessForInitialSettings().execute();
}
public void setLeftRightLayout() {
FragmentTransaction newtransaction = getFragmentManager()
.beginTransaction();
newtransaction.replace(R.id.myfragmentleft, leftLayout);
newtransaction.replace(R.id.myfragmentright, rightLayout);
newtransaction.addToBackStack(null);
newtransaction.commit();
}
@Override
public void onBackPressed() {
finish();
}
public class BackgrndProcessForInitialSettings extends
AsyncTask<Void, Void, Integer> {
@Override
protected void onPreExecute() {
super.onPreExecute();
progressDialog = ProgressDialog.show(MainLayout.this, "",
"please wait...");
}
@Override
protected Integer doInBackground(Void... params) {
setLeftRightLayout();
return 1;
}
@Override
protected void onPostExecute(Integer result) {
progressDialog.dismiss();
super.onPostExecute(result);
}
}
}
错误日志:1
错误日志:2
错误日志:3