validateClientPermissionsLocked: Caller “package” cannot open camera “1” from background'
Trying to capture photo from front camera when the app is in background.
I have the below code working in android 6 and below.
Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
cameraCount = Camera.getNumberOfCameras();
for (int camIdx = 0; camIdx < cameraCount; camIdx++)
{
Camera.getCameraInfo(camIdx, cameraInfo);
if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_FRONT)
{
myCamera = Camera.open(camIdx);
}
}
This works in android 7 and above only if the app is in foreground. If the app is in background it shows the below error:
W/CameraBase: An error occurred while connecting to camera 1: Status(-8): '6: validateClientPermissionsLocked:915: Caller "packagename" (PID 10152, UID 32606) cannot open camera "1" from background'
W/System.err: java.lang.RuntimeException: Fail to connect to camera service
W/System.err: at android.hardware.Camera.<init>(Camera.java:546)
W/System.err: at android.hardware.Camera.open(Camera.java:392)
W/System.err: at com.tracking_smartphone.TakePictureActivity.takePictureNoPreview(TakePictureActivity.java:77)
W/System.err: at com.tracking_smartphone.TakePictureActivity.onCreate(TakePictureActivity.java:46)
W/System.err: at android.app.Activity.performCreate(Activity.java:7144)
W/System.err: at android.app.Activity.performCreate(Activity.java:7135)
W/System.err: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
W/System.err: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2894)
W/System.err: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3049)
W/System.err: at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
W/System.err: at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
W/System.err: at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
W/System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1809)
W/System.err: at android.os.Handler.dispatchMessage(Handler.java:106)
W/System.err: at android.os.Looper.loop(Looper.java:193)
W/System.err: at android.app.ActivityThread.main(ActivityThread.java:6680)
W/System.err: at java.lang.reflect.Method.invoke(Native Method)
W/System.err: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
The code is called in an Activity which is invoked from a JobService.
android android-activity
add a comment |
Trying to capture photo from front camera when the app is in background.
I have the below code working in android 6 and below.
Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
cameraCount = Camera.getNumberOfCameras();
for (int camIdx = 0; camIdx < cameraCount; camIdx++)
{
Camera.getCameraInfo(camIdx, cameraInfo);
if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_FRONT)
{
myCamera = Camera.open(camIdx);
}
}
This works in android 7 and above only if the app is in foreground. If the app is in background it shows the below error:
W/CameraBase: An error occurred while connecting to camera 1: Status(-8): '6: validateClientPermissionsLocked:915: Caller "packagename" (PID 10152, UID 32606) cannot open camera "1" from background'
W/System.err: java.lang.RuntimeException: Fail to connect to camera service
W/System.err: at android.hardware.Camera.<init>(Camera.java:546)
W/System.err: at android.hardware.Camera.open(Camera.java:392)
W/System.err: at com.tracking_smartphone.TakePictureActivity.takePictureNoPreview(TakePictureActivity.java:77)
W/System.err: at com.tracking_smartphone.TakePictureActivity.onCreate(TakePictureActivity.java:46)
W/System.err: at android.app.Activity.performCreate(Activity.java:7144)
W/System.err: at android.app.Activity.performCreate(Activity.java:7135)
W/System.err: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
W/System.err: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2894)
W/System.err: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3049)
W/System.err: at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
W/System.err: at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
W/System.err: at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
W/System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1809)
W/System.err: at android.os.Handler.dispatchMessage(Handler.java:106)
W/System.err: at android.os.Looper.loop(Looper.java:193)
W/System.err: at android.app.ActivityThread.main(ActivityThread.java:6680)
W/System.err: at java.lang.reflect.Method.invoke(Native Method)
W/System.err: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
The code is called in an Activity which is invoked from a JobService.
android android-activity
Were you able to solve this issue
– Prakhar Asthana
Jan 11 at 8:04
add a comment |
Trying to capture photo from front camera when the app is in background.
I have the below code working in android 6 and below.
Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
cameraCount = Camera.getNumberOfCameras();
for (int camIdx = 0; camIdx < cameraCount; camIdx++)
{
Camera.getCameraInfo(camIdx, cameraInfo);
if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_FRONT)
{
myCamera = Camera.open(camIdx);
}
}
This works in android 7 and above only if the app is in foreground. If the app is in background it shows the below error:
W/CameraBase: An error occurred while connecting to camera 1: Status(-8): '6: validateClientPermissionsLocked:915: Caller "packagename" (PID 10152, UID 32606) cannot open camera "1" from background'
W/System.err: java.lang.RuntimeException: Fail to connect to camera service
W/System.err: at android.hardware.Camera.<init>(Camera.java:546)
W/System.err: at android.hardware.Camera.open(Camera.java:392)
W/System.err: at com.tracking_smartphone.TakePictureActivity.takePictureNoPreview(TakePictureActivity.java:77)
W/System.err: at com.tracking_smartphone.TakePictureActivity.onCreate(TakePictureActivity.java:46)
W/System.err: at android.app.Activity.performCreate(Activity.java:7144)
W/System.err: at android.app.Activity.performCreate(Activity.java:7135)
W/System.err: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
W/System.err: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2894)
W/System.err: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3049)
W/System.err: at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
W/System.err: at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
W/System.err: at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
W/System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1809)
W/System.err: at android.os.Handler.dispatchMessage(Handler.java:106)
W/System.err: at android.os.Looper.loop(Looper.java:193)
W/System.err: at android.app.ActivityThread.main(ActivityThread.java:6680)
W/System.err: at java.lang.reflect.Method.invoke(Native Method)
W/System.err: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
The code is called in an Activity which is invoked from a JobService.
android android-activity
Trying to capture photo from front camera when the app is in background.
I have the below code working in android 6 and below.
Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
cameraCount = Camera.getNumberOfCameras();
for (int camIdx = 0; camIdx < cameraCount; camIdx++)
{
Camera.getCameraInfo(camIdx, cameraInfo);
if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_FRONT)
{
myCamera = Camera.open(camIdx);
}
}
This works in android 7 and above only if the app is in foreground. If the app is in background it shows the below error:
W/CameraBase: An error occurred while connecting to camera 1: Status(-8): '6: validateClientPermissionsLocked:915: Caller "packagename" (PID 10152, UID 32606) cannot open camera "1" from background'
W/System.err: java.lang.RuntimeException: Fail to connect to camera service
W/System.err: at android.hardware.Camera.<init>(Camera.java:546)
W/System.err: at android.hardware.Camera.open(Camera.java:392)
W/System.err: at com.tracking_smartphone.TakePictureActivity.takePictureNoPreview(TakePictureActivity.java:77)
W/System.err: at com.tracking_smartphone.TakePictureActivity.onCreate(TakePictureActivity.java:46)
W/System.err: at android.app.Activity.performCreate(Activity.java:7144)
W/System.err: at android.app.Activity.performCreate(Activity.java:7135)
W/System.err: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
W/System.err: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2894)
W/System.err: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3049)
W/System.err: at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
W/System.err: at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
W/System.err: at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
W/System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1809)
W/System.err: at android.os.Handler.dispatchMessage(Handler.java:106)
W/System.err: at android.os.Looper.loop(Looper.java:193)
W/System.err: at android.app.ActivityThread.main(ActivityThread.java:6680)
W/System.err: at java.lang.reflect.Method.invoke(Native Method)
W/System.err: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
The code is called in an Activity which is invoked from a JobService.
android android-activity
android android-activity
asked Jan 3 at 10:27
Srihari KaranthSrihari Karanth
862918
862918
Were you able to solve this issue
– Prakhar Asthana
Jan 11 at 8:04
add a comment |
Were you able to solve this issue
– Prakhar Asthana
Jan 11 at 8:04
Were you able to solve this issue
– Prakhar Asthana
Jan 11 at 8:04
Were you able to solve this issue
– Prakhar Asthana
Jan 11 at 8:04
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54020430%2fvalidateclientpermissionslocked-caller-package-cannot-open-camera-1-from-ba%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54020430%2fvalidateclientpermissionslocked-caller-package-cannot-open-camera-1-from-ba%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Were you able to solve this issue
– Prakhar Asthana
Jan 11 at 8:04