我运行以下行来预览我的网络摄像头:
...
public MediaCapture VideoCaptureSource { get; set; }
var cameras = await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture);
if (cameras.Count == 1)
{
settings = new MediaCaptureInitializationSettings { VideoDeviceId = cameras[0].Id };
}
else
{
settings = new MediaCaptureInitializationSettings { VideoDeviceId = cameras[1].Id };
}
await _mediaCapture.InitializeAsync(settings);
VideoCaptureSource = _mediaCapture;
await VideoCaptureSource.StartPreviewAsync();
...
Run Code Online (Sandbox Code Playgroud)
这是我的XAML:
<Canvas Width="640" Height="360">
<CaptureElement Source="{Binding VideoCaptureSource}" Visibility="{Binding VideoCaptureVisibility}" Width="640" Height="360" />
<Image Source="{Binding CaptureImageSource}" Visibility="{Binding CaptureImageVisibility, FallbackValue=Collapsed}" Width="640" Height="360" />
</Canvas>
Run Code Online (Sandbox Code Playgroud)
一切正常,直到我调用StartPreviewAsyn() - Method.不幸的是,我只收到一条不太有用的错误消息:"请求的操作中发生意外错误." 我试图在我的本地机器和模拟器上运行代码.有谁知道我做错了什么?
环境是Windows 8.1,Caliburn.Micro,ZXing.Net 0.12.0.0,VS 2013
PlacePicker是一个有用的小部件com.google.android.gms:play-services-places:9.4.0.在此处查找说明:PlacePicker
该文档明确指出您需要ACCESS_FINE_LOCATION权限才能使用它.
在Marshmallow及以上,您还必须要求用户授予此权限.
但它似乎没有做任何这个工作!
我的应用程序
但是在Marshmallow设备上运行应用程序会启动PlacePicker,我可以
任何人都可以确认这个或解释为什么这个小部件工作没有授予适当的权限?
android android-permissions google-maps-android-api-2 android-6.0-marshmallow
假设我们有一个BottomNavigationBar,顶部有一个FAB。使用此设置并显示小吃栏时,小吃栏应出现在BottomNavigationBar上方,并在出现/关闭时向上/向下推FAB。
这是使用CoordinatorLayout的常见方案。是否还可以使用新的MotionLayout创建此动画?
Bug跟踪器中存在一个问题,但由于OP并未明确提出问题,因此该问题已关闭(https://issuetracker.google.com/issues/112665540)
我在尝试时遇到的问题:我们无权访问Snackbar的layout-id。我们也无权访问Snackbar的常规xml,因此我们无法设置其Constraints。
更新:我知道一段代码将有助于回答这个问题。但是我想出的那段代码根本没有用。我现在指出了两个主要问题:
我不知道Snackbar的layout-id。因此,我不能在编写场景描述时使用它。
即使我可以创建一个场景描述(例如,State1:SnackBar可见,State2:Snackbar不可见)。我必须手动触发这些场景过渡。这意味着我将重新创建自己的Snackbar,而不是按预期使用原始的Snackbar。
评论: @mikejonesguy是的,我认为它们相似。不一样,但是相似。而且MotionLayout确实具有您所描述的工作:协调其子视图之间的交互。用“动画”代替“坐标”,您会明白我的意思。还可以查看OnSwipe / OnClick处理程序。MotionLayout仍然很新鲜,但我认为将来它将以ConstraintLayout替换RelativeLayout的相同方式替换CoordinatorLayout。也许我错了,也许没有...时间会证明一切。
结论: 就我而言,似乎还没有办法仅通过使用MotionLayout来实现我想要的功能。如果有一天,我将通过一个可行的示例来更新此问题。对不起,不可能的赏金... :)
android android-snackbar android-constraintlayout android-architecture-components android-motionlayout
更新:
我刚刚在另一台设备上测试了我的应用程序,发现我确实在运行Android 4.4.2的Nexus 4上出现了错误,但没有在运行Android 4.0.4的Desire S上出现错误.他们都安装了当前的YouTube应用程序(5.3.32),这是使用API所必需的.
问题:为什么我会收到这些ServiceConnectionLeaked消息?(见下面的Logcat)
描述:
我正在使用YouTube Android Player API 1.0.0(https://developers.google.com/youtube/android/player/)使用以下适配器代码在ListView中加载视频缩略图:
private final Map<View, YouTubeThumbnailLoader> mThumbnailViewToLoaderMap;
public ListViewAdapter(Activity activity, int layoutId, List<Suggestion> suggestions) {
super(activity, layoutId, suggestions);
mThumbnailViewToLoaderMap = new HashMap<View, YouTubeThumbnailLoader>();
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
String videoId = getYoutubeId();
// There are three cases here...
if (convertView == null) {
convertView = LayoutInflater.from(mActivity).inflate(R.layout.row_suggestion, parent, false);
holder = new ViewHolder();
holder.thumbnailView = (YouTubeThumbnailView) convertView.findViewById(R.id.youtubeThumbnail); …Run Code Online (Sandbox Code Playgroud) android listview thumbnails serviceconnection android-youtube-api
我正在使用带有场景 xml 的 MotionLayout:
<Transition
motion:constraintSetStart="@+id/start"
motion:constraintSetEnd="@+id/end"
>
<OnSwipe
motion:touchAnchorId="@+id/v_top_sheet"
motion:touchRegionId="@+id/v_top_sheet_touch_region"
motion:touchAnchorSide="bottom"
motion:dragDirection="dragDown" />
</Transition>
Run Code Online (Sandbox Code Playgroud)
2ConstraintSets只引用了 2 个视图 ID:v_notifications_container和v_top_sheet。
在我的活动中,我想将一个普通的 ClickListener 设置为这个 MotionLayout 中的其他视图之一:
iv_notification_status.setOnClickListener { Timber.d("Hello") }
Run Code Online (Sandbox Code Playgroud)
执行此行,但从未触发 ClickListener。我搜索了其他帖子,但其中大多数都涉及在与motion:touchAnchorId. 这不是这里的情况。ClickListener 设置为在 MotionLayout 设置中未曾提及的视图。如果我删除该app:layoutDescription属性,则单击有效。
我也尝试使用setOnTouchListener,但它也从未被调用过。
如何在 MotionLayout 中设置单击侦听器?
android onclicklistener android-constraintlayout android-motionlayout
我正在尝试使用 Web Midi API 构建一个 Angular2 项目。
运行时ng build,由于抛出了某些错误,我无法完成该过程,特别是:
保释模式错误:[默认] /Users/JmsToh/GitHub/web-editor/web-editor/src/app/midi.service.ts:43:22 “导航器”类型上不存在属性“requestMIDIAccess”。
这来自这部分代码:
if (navigator.requestMIDIAccess) {
this.browserMidiCompatible = true;
navigator.requestMIDIAccess({ sysex: false })
.then(this.onMIDISuccess.bind(this), this.onMIDIReject.bind(this));
} else {
alert("Platform not compatible");
}
Run Code Online (Sandbox Code Playgroud)
运行时该应用程序在 Chrome 上运行良好ng serve。有没有办法让 Angular2 在构建时忽略错误?
在为我正在使用的所有库添加ProGuard规则后,我仍然收到以下警告:
警告:有14个未解决的对类或接口的引用。
您可能需要添加缺少的库jar或更新其版本。
如果您的代码正常运行而没有缺少类,则可以取消
带“ -dontwarn”选项的警告。
(http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedclass)
我知道我可能可以使用该-dontwarn选项来消除此警告,但是因此我需要知道无法解析哪些包/类/接口。Android不支持全局“ -dontwarn”。
在日志文件中,我发现了很多注释和警告,但是似乎没有一个与以上消息相关。
我正在为 Jetpack 的 Paging 3 Library 苦苦挣扎。
我设置
在PagingSource由空间中创建的。
我知道RemoteMediators 的职责是从网络中获取项目并将它们保存到 Room 数据库中。通过这样做,我们可以使用 Room 数据库作为单一事实点。PagingSource只要我使用整数作为 .Room就可以轻松地为我创建nextPageKeys.
到现在为止还挺好。这是我的 ViewModel 来检索以下列表Sources:
private lateinit var _sources: Flow<PagingData<Source>>
val sources: Flow<PagingData<Source>>
get() = _sources
private fun fetchSources() = viewModelScope.launch {
_sources = sourcesRepository.getSources(
selectedRepositoryUuid,
selectedRef,
selectedPath
)
}
Run Code Online (Sandbox Code Playgroud)
val sources收集在Fragment.
fetchSources()每当三个参数之一发生变化时调用 ( selectedRepositoryUuid, selectedRefor selectedPath)
这是 Paging 调用的存储库 …
android android-room android-jetpack android-paging android-paging-library
考虑以下简单设置。1 个片段与 1 个 ViewModel:
分段
class TestFragment : Fragment() {
private val viewModel by lazy {
ViewModelProviders.of(this).get(TestViewModel::class.java)
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return inflater.inflate(R.layout.fragment_test, container, false)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
viewModel.testLiveData.observe(viewLifecycleOwner, androidx.lifecycle.Observer {
Log.d("###", "whattt")
})
}
}
Run Code Online (Sandbox Code Playgroud)
视图模型
class TestViewModel : ViewModel() {
private val myVariable = Log.d("###", "Test")
val testLiveData = MutableLiveData(false)
}
Run Code Online (Sandbox Code Playgroud)
为什么我从 Fragment 和 ViewModel 获得最多三倍的日志输出?
D/###: Test
D/###: whattt
D/###: Test
D/###: …Run Code Online (Sandbox Code Playgroud) android kotlin android-livedata android-viewmodel android-architecture-components
我已经连接了我的菜单 xml 和 Android 导航组件navigation_view.setupWithNavController(navController),一切正常。我的菜单的一部分是注销选项。如果用户选择此导航目的地,应用程序应导航到AuthorizationFragment 并将返回堆栈弹出到此 Fragment 并将 inclusive 设置为 true以删除所有先前的Fragment。
我查看了导航库的代码,并达到了应该发生这种情况的地步:
NavigationUI.onNavDestinationSelected():
/**
* Attempt to navigate to the {@link NavDestination} associated with the given MenuItem. This
* MenuItem should have been added via one of the helper methods in this class.
*
* <p>Importantly, it assumes the {@link MenuItem#getItemId() menu item id} matches a valid
* {@link NavDestination#getAction(int) action id} or
* {@link NavDestination#getId() destination id} to be navigated to.</p>
* <p> …Run Code Online (Sandbox Code Playgroud) android navigation-drawer android-navigation android-navigationview android-jetpack
我有这个 lambda,我想返回 String via 的结果CommonIdFacade.commonId,但实际返回的是函数。MDC.get返回一个字符串
typealias CommonIdFactory = () -> String
class CommonIdFacade {
companion object {
var commonId: CommonIdFactory = { MDC.get("someKey") }
internal set
}
}
Run Code Online (Sandbox Code Playgroud) android ×8
android-architecture-components ×2
kotlin ×2
android-room ×1
angular ×1
apk ×1
c# ×1
listview ×1
thumbnails ×1
webcam ×1
windows-8 ×1
winrt-xaml ×1
zxing ×1