1。我有这段代码向我询问权限,但是当我关闭应用程序时,我忘记了它们,然后像我一样再次询问它们,这样我就不再从版本6.0到顶部再次询问该权限。 Android。
2。因此,您只需要一次许可即可,就像大型应用程序一样。
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (datos==null && code==0){
start();
}else{
startService(Conector.newIntent(TakeScreen.this, code, datos));
finish();
Toast.makeText(TakeScreen.this,"has data",Toast.LENGTH_SHORT).show();
}
}
public void start(){
MediaProjectionManager mgr = (MediaProjectionManager) getSystemService(MEDIA_PROJECTION_SERVICE);
startActivityForResult(mgr.createScreenCaptureIntent(), REQUEST_CODE_MEDIA_PROJECTION);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case REQUEST_CODE_MEDIA_PROJECTION: {
if (resultCode == RESULT_OK) {
if(data!=null){
code=resultCode;
datos=data;
startService(Conector.newIntent(TakeScreen.this, code, datos));
}else{
Toast.makeText(getApplicationContext(),"Error",Toast.LENGTH_SHORT).show();
}
} else {
variableVN();
Toast.makeText(getApplicationContext(),"Permiso denegado",Toast.LENGTH_SHORT).show();
Intent intent = new Intent(this, FloatinBoton.class);
stopService(intent);
}
finishAndRemoveTask();
break;
}
}
}