最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

java - Android:Unable to connect to chromecast from app in development when in kiosk mode - Stack Overflow

programmeradmin8浏览0评论

I am developing an app for android12. The app is a kiosk mode and uses startLockTask.

To use the standard Android cast function from the app, to call the cast settings screen.

startActivity(new Intent(ACTION_CAST_SETTINGS));

I can display the settings screen, and I can connect to FireTV, I can connect to Chromecast, but I cannot connect to Chromecast. The connection is still in progress.

I found that a confirmation message “start recording or casting?” is displayed at the time of connection, but it was not displayed on my app.

It does appear when I execute stopLockTask just before the connection, Is there any way to make it appear while using startLockTask?

I am developing an app for android12. The app is a kiosk mode and uses startLockTask.

To use the standard Android cast function from the app, to call the cast settings screen.

startActivity(new Intent(ACTION_CAST_SETTINGS));

I can display the settings screen, and I can connect to FireTV, I can connect to Chromecast, but I cannot connect to Chromecast. The connection is still in progress.

I found that a confirmation message “start recording or casting?” is displayed at the time of connection, but it was not displayed on my app.

It does appear when I execute stopLockTask just before the connection, Is there any way to make it appear while using startLockTask?

Share Improve this question edited Jan 18 at 7:29 Kobo asked Jan 18 at 7:27 KoboKobo 255 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

This is actually a known limitation with Android's kiosk mode(Lock Task) mode and system dialogs. However you can handle this by adding cast permission to allowed activities.

You can whitelist specific system UI components in your Device owner settings. You need to use DevicePolicyManager to set this up.

DevicePolicyManager dpm = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);
String[] packages = {
    "com.google.android.gms",

*// Google Play Services*

"com.google.android.apps.chromecast.app"

*// Cast related*

};
dpm.setLockTaskPackages(admin, packages);

Please check and update if this works for you.

发布评论

评论列表(0)

  1. 暂无评论