我最近偶然发现了这条消息,我很确定这个构造函数在 18.0.0 之前的版本中没有被弃用,但我也找不到任何地方也找不到这个构造函数已被弃用的信息。
我们应该使用什么来代替,有没有另一种方法来创建一个locationRequest?
android kotlin google-maps-android-api-2 google-location-services
我有一个使用应用程序内更新的 Android 应用程序。以 android 14 (API 34) 为目标后,应用程序将因以下错误而无法启动:
\nFATAL EXCEPTION: main\nProcess: no.norva24.mslam, PID: 8281\njava.lang.RuntimeException: Unable to start activity\nComponentInfo{no.norva24.mslam/no.norva24.mslam.ui.activities.MainActivity}: java.lang.SecurityException: no.norva24.mslam: One\nof RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered\nexclusively for system broadcasts\n at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3782)\n at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3922)\n at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103)\n at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:139)\n at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:96)\n at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2443)\n at android.os.Handler.dispatchMessage(Handler.java:106)\n at android.os.Looper.loopOnce(Looper.java:205)\n at android.os.Looper.loop(Looper.java:294)\n at android.app.ActivityThread.main(ActivityThread.java:8176)\n at java.lang.reflect.Method.invoke(Native Method)\n at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)\n at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)\nCaused by: java.lang.SecurityException: no.norva24.mslam: One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED\nshould be specified when a receiver isn't being registered …Run Code Online (Sandbox Code Playgroud) 以下FetchAddressIntentService实现IntentService(在 kotlin 中):
class FetchAddressIntentService //Constructor of this service
: IntentService(INTENTTAG) {
//Receiver where results are forwarded from this service
protected var resultReceiver: ResultReceiver? = null
private val TAG by lazy { this::class.java.simpleName }
//Intent Service handler
override fun onHandleIntent(intent: Intent?) { //Errormessages
var errorMessage = ""
if (intent != null) {
resultReceiver =
intent.getParcelableExtra(RECEIVER)
}
//Checks if receiver was properly registered
if (resultReceiver == null) {
Log.wtf(
TAG,
"No reciever received. There is nowhere to …Run Code Online (Sandbox Code Playgroud) android kotlin android-intentservice jobintentservice android-11
我试图在我的应用程序中使用 Flow 将我的 Paging 2 实现转换为 Paging 3,但受到“Channel was closed”异常的困扰。该应用程序运行良好,但在一段时间后崩溃(从几秒钟到几分钟)。它从网络加载数据,这可能很慢。使用 Room 作为内部数据库。模拟器上的崩溃比真实设备上的要频繁得多。
我不熟悉 Flow,我应该注意 Flow 系统中是否有任何已知的罪魁祸首?
有没有其他人在使用 androidx 的 Paging 3 时遇到过类似的情况?
因此,如果这是一个已知问题(可能有明显的修复方法),请给我一个提示;与否,我可能会发布 Paging 3 代码部分(这将需要一些时间)。
我的异常如下所示:
2020-06-29 09:23:59.929 28295-28295/no.rogo.emptyfuel E/AndroidRuntime: FATAL EXCEPTION: main
Process: no.rogo.emptyfuel, PID: 28295
kotlinx.coroutines.channels.ClosedSendChannelException: Channel was closed
at kotlinx.coroutines.channels.Closed.getSendException(AbstractChannel.kt:1035)
at kotlinx.coroutines.channels.AbstractSendChannel.helpCloseAndResumeWithSendException(AbstractChannel.kt:206)
at kotlinx.coroutines.channels.AbstractSendChannel.access$helpCloseAndResumeWithSendException(AbstractChannel.kt:19)
at kotlinx.coroutines.channels.AbstractSendChannel.sendSuspend(AbstractChannel.kt:196)
at kotlinx.coroutines.channels.AbstractSendChannel.send(AbstractChannel.kt:135)
at kotlinx.coroutines.channels.ChannelCoroutine.send$suspendImpl(Unknown Source:2)
at kotlinx.coroutines.channels.ChannelCoroutine.send(Unknown Source:0)
at androidx.paging.PageFetcherSnapshot$pageEventFlow$1$2$invokeSuspend$$inlined$collect$1.emit(Collect.kt:137)
at kotlinx.coroutines.flow.FlowKt__ChannelsKt.emitAllImpl$FlowKt__ChannelsKt(Channels.kt:58)
at kotlinx.coroutines.flow.FlowKt__ChannelsKt$emitAllImpl$1.invokeSuspend(Unknown Source:11)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:56)
at kotlinx.coroutines.EventLoop.processUnconfinedEvent(EventLoop.common.kt:69)
at kotlinx.coroutines.DispatchedTaskKt.resumeUnconfined(DispatchedTask.kt:184)
at kotlinx.coroutines.DispatchedTaskKt.dispatch(DispatchedTask.kt:108)
at kotlinx.coroutines.CancellableContinuationImpl.dispatchResume(CancellableContinuationImpl.kt:308)
at kotlinx.coroutines.CancellableContinuationImpl.completeResume(CancellableContinuationImpl.kt:395)
at …Run Code Online (Sandbox Code Playgroud) 致力于jetpackcompose在 Android Studio 4.0 Canary 中了解 android 。
我有一个简单的jetpackcompose设置,VerticalScroller如下所示:
@Composable
fun MyScreenContent(appState: AppState = AppState())
{
FlexColumn{
flexible(flex = 1f){
VerticalScroller {
Column {
CardDemo()
CardDemo()
CardDemo()
CardDemo()
CardDemo()
CardDemo()
CardDemo()
CardDemo()
CardDemo()
CardDemo()
CardDemo()
CardDemo()
CardDemo()
CardDemo()
CardDemo()
CardDemo()
CardDemo()
CardDemo()
CardDemo()
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
它完美地滚动,但我想要一个scrollindicator显示我的列表滚动了多远,我如何打开它,找不到任何ScrollIndicator(即)组件来包含。
参考 到RecyclerView在非可组合设置(XML),其中scrollindicator是可见的:
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/station_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/recyclerview_background_color"
android:clipChildren="true"
android:clipToPadding="false"
android:fadeScrollbars="false"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:scrollbarSize="4dp"
android:scrollbarThumbVertical="@color/colorPrimary" <---
android:scrollbars="vertical" <--- …Run Code Online (Sandbox Code Playgroud) 我有以下场景:
芯片定义:
<chip xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
app:chipIcon="@drawable/ic_baseline_house_24"
android:text="@string/chips_holder"
app:closeIconEnabled="true"
/>
Run Code Online (Sandbox Code Playgroud)
包含 TextInputTeditText 的 xml 部分:
...
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense"
android:enabled="true"
android:hint="Gallery Selections"
android:layout_weight="1">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/fragment_gallery_text_input_edit_text_selections"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="false"
android:cursorVisible="false"
android:focusable="false"
android:focusableInTouchMode="false" />
</com.google.android.material.textfield.TextInputLayout>
...
Run Code Online (Sandbox Code Playgroud)
房间 liveData 结果观察器,提供来自一组变量的数据:
...
liveDataFilterGallery?.observe(
viewLifecycleOwner
){filterGalleryResult->
filterGalleryResult?.let { safeFilterGalleryResult->
safeFilterGalleryResult.apply {
val prefixes = arrayOf(
"Site No",
"Farm No",
"Site Id",
"Assignment Id",
"Category",
"Time Stamp")
fragmentGalleryTextInputEditTextSelections.setText(
(if(siteNo.isNullOrEmpty()) "" else "${prefixes[0]} = '$siteNo';") +
(if(farmNo.isNullOrEmpty()) "" else "${prefixes[1]} = '$farmNo';") +
(if(siteId.isNullOrEmpty()) "" else "${prefixes[2]} …Run Code Online (Sandbox Code Playgroud) android drawable kotlin android-chips android-textinputedittext
android ×6
kotlin ×3
android-11 ×1
android-14 ×1
androidx ×1
drawable ×1
kotlin-flow ×1
scrollbar ×1