屏幕闪烁为android中的前置摄像头

时间:2016-01-08 15:19:04

标签: android android-camera

我尝试创建屏幕闪烁前置摄像头应用程序,但我无法做到这一点。这是我的代码,请帮助完成此操作。

  • 我使用camera2 api进行相机活动
  • 为屏幕闪烁创建新活动
  • 不参与相机活动,但无法正常工作 请给我解决方案

Camera2Fragment.java

 @Override
 public void onClick(View view) {
        switch (view.getId()) {
                case R.id.picture: {
                    startActivityForResult(new Intent(getActivity(),SplashActivity.class),1);
                    takePicture();
                    break;
                }
                case R.id.info: {
                        Activity activity = getActivity();
                        if (null != activity) {
                                new AlertDialog.Builder(activity)
                                        .setMessage(" This sample demonstrates the basic use of Camera2" +
                                                " API. Check the source code to see how  you can display camera preview and take pictures.")
                                        .setPositiveButton(android.R.string.ok, null)
                                        .show();
                        }
                        break;
                }
        }
}

SplashActivity.java

public class SplashActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);
        h=new Handler();
        cResolver=getContentResolver();
        changeBright=255;
        window = getWindow();
//if(ContextCompat.checkSelfPermission(SplashActivity, Manifest.permission.SETT))
 Settings.System.putInt(cResolver,Settings.System.SCREEN_BRIGHTNESS,changeBright);
        WindowManager.LayoutParams layourPars=window.getAttributes();
        layourPars.screenBrightness=changeBright/(float)255;``
        Timer timer = new Timer();
        timer.schedule(new TimerTask() {
            public void run() {
                Intent openMain = new Intent(SplashActivity.this, MainActivity.class);
                openMain.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
                startActivity(openMain);

            }
        }, 1000);
        SplashActivity.this.setResult(1);
    }

}

0 个答案:

没有答案