Salve non riesco a capire come mai il mio video sia che sia in esecuzione che quando termina, nel momento in cui il mio smartphone va in standby se rientro crasha tutto e il telefono non va piu...bisogna togliere addirittura la batteria...come si puo'risolvere?
vi posto il codice:
codice:public class Video3Fragment extends Fragment{ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { v = inflater.inflate(R.layout.fragment_video3, container, false); //set the path where we want to save the file File SDCardRoot = Environment.getExternalStorageDirectory(); //create a new file, to save the downloaded file // recupero il percorso del file file = new File(SDCardRoot+"/PersonalTrainer/","lat_machine.mp4"); video= (VideoView) v.findViewById(R.id.videoView1); getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); image=(ImageView) v.findViewById(R.id.imageView1); image.setClickable(true); return v; } public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); // secondo avvio if(file.exists()){ image.setVisibility(View.INVISIBLE); video.setVideoPath(file.getPath()); video.setOnPreparedListener (new OnPreparedListener() { @Override public void onPrepared(MediaPlayer mp) { mp.setLooping(true); } }); video.start(); } //primo avvio else{ image.setOnClickListener(new OnClickListener(){ public void onClick(View arg0) { if(!haveNetworkConnection()){ createNetErrorDialog(); flag=false; } else flag=true; if(flag){ showProgress(dwnload_file_path); new Thread(new Runnable() { public void run() { downloadFile(); } }).start(); } } }); } }
grazie in anticipo

Rispondi quotando