I have faced the same problem. If you see the example comes with the compiledSdKversion 22 because in newer versions the user have to explicitly give the Camera permission. My project is working with API 25 by adding some code to my android application. In my case, I asked for the Camera Permission before opening the vuforia activity when an user clic a FloatingActionButton:
FloatingActionButton flb=(FloatingActionButton)findViewById(R.id.floatingActionButton2);
flb.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(MainActivity.this, new String[] { Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE }, 0);
}
else
{
Intent myIntent = new Intent(MainActivity.this, VideoPlayback.class);
startActivity(myIntent);
}
}
});
The VideoPlayback is the activity that use AR from vuforia included in the advance examples. In this case you have to listen to an onRequestPermissionsResult because we have to check the user's answer.
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
// Begin monitoring for Aruba Beacon-based Campaign events
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (requestCode == 0) {
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED
&& grantResults[1] == PackageManager.PERMISSION_GRANTED) {
Intent myIntent = new Intent(MainActivity.this, VideoPlayback.class);
startActivity(myIntent);
}
}
}
In the onRequestPermissionsResult we check if the answer was positive an if so we open the activity.
I hope it works for you too.