我尝试创建屏幕闪烁前置摄像头应用程序,但我无法做到这一点。这是我的代码,请帮助完成此操作。
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);
}
}