public class PreviewActivity extends Activity {
public static final String VIDEO_FOLDER_PATH = PropagandaVedioSettings.path;
private static final String TAG = "PreviewActivity";
// private PowerManager.WakeLock localWakeLock = null;
// private PowerManager.WakeLock wl;
private PowerManager pm;
private WakeLock mWakelock;
private SurfaceView surfaceView = null;
private SurfaceHolder holder = null;
private MediaPlayer mPlayer = null;
private int sourceIndex = -1;//当前视频文件下标
public String[] sourceList;
private boolean isFirst = true;//是否是第一次被加载
FileList filelist = new FileList();
public void onCreate(Bundle paramBundle) {
super.onCreate(paramBundle);
requestWindowFeature(Window.FEATURE_NO_TITLE); //隐藏标题栏
//全屏
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN
, WindowManager.LayoutParams.FLAG_FULLSCREEN);
System.gc();
setRequestedOrientation(0);// 改变内容显示的方向
// localWakeLock = ((PowerManager) getSystemService(Context.POWER_SERVICE))
// .newWakeLock(PowerManager.FULL_WAKE_LOCK, "DoNotDimScreen");
// localWakeLock.acquire();//让设备不自动锁屏
// PowerManager.WakeLock localWakeLock = ((PowerManager)getSystemService("power")).newWakeLock(26, "DoNotDimScreen");
pm = (PowerManager)getSystemService(POWER_SERVICE);
mWakelock = pm.newWakeLock(PowerManager.ACQUIRE_CAUSES_WAKEUP|PowerManager.FULL_WAKE_LOCK, "PreviewActivity");
mWakelock.acquire();// 点亮
View view = getLayoutInflater().inflate(R.layout.surfaceview, null);
setContentView(view);
Log.i(TAG, "Activity begin start ");
Bundle bundle = getIntent().getExtras();
if(bundle != null){
sourceList = bundle.getStringArray("sourceList");
sourceIndex = bundle.getInt("sourceIndex");
System.out.println("bundle is not null");
}else{
System.out.println("bundle is null");
filelist.fillVideoList();
}
mPlayer = new MediaPlayer();
surfaceView = (SurfaceView)findViewById(R.id.surfaceView);
surfaceView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
finish();
return false;
}
});