I am writing a basic ArCore app. But the ArFragment is displaying a blinking sign only when I place it horizontally to detect plane surface. Also the camera permission is missing when I test it using my Sony experia. I am not sure if my phone is supported because I don't really know the exact model of my phone. Following is my permission and some of the initializing code.
//Permission request
public boolean isCameraPermissionGranted(Activity host){
// if the device isn't compatible return false
if(!host.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA) &&
!host.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_AR)){
return false;
}
if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA)
!= PackageManager.PERMISSION_GRANTED) {
// Permission is not granted
// Should we show an explanation?
if (ActivityCompat.shouldShowRequestPermissionRationale(host, Manifest.permission.CAMERA)) {
// Show an explanation to the user *asynchronously* -- don't block
// this thread waiting for the user's response! After the user
// sees the explanation, try again to request the permission.
} else {
// No explanation needed; request the permission
ActivityCompat.requestPermissions(host, new String[]{Manifest.permission.CAMERA},
MY_PERMISSIONS_REQUEST_CAMERA);
}
} else {
// Permission has already been granted
return true;
}
return false;
}
//onCreate
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.image_activity_layout)
utils = Utils(applicationContext)
if(utils.isCameraPermissionGranted(this) && utils.isStoragePermissionGranted(this))
utils.maybeEnableAr()
//loadCamera()
arFragment = supportFragmentManager.findFragmentById(R.id.f_sceneform_fragment) as ArFragment
// Adds a listener to the ARSceneView
// Called before processing each frame
arFragment.arSceneView.scene.addOnUpdateListener { frameTime ->
arFragment.onUpdate(frameTime)
//onUpdate()
}
}
//Manifest
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.ar" android:required="true"/>
//This the fragment
<fragment
android:id="@+id/f_sceneform_fragment"
android:name="com.google.ar.sceneform.ux.ArFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
This is the screen I am seeing.
Added simple permission as follows:
<uses-permission android:name="android.permission.CAMERA" />