我使用了较新的NotificationCompat构建器,但我无法收到通知以发出声音.它会振动并闪烁光线.android文档说要设置我已完成的样式:
builder.setStyle(new NotificationCompat.InboxStyle());
Run Code Online (Sandbox Code Playgroud)
但没声音?
完整代码:
NotificationCompat.Builder builder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle("Notifications Example")
.setContentText("This is a test notification");
Intent notificationIntent = new Intent(this, MenuScreen.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent,
PendingIntent.FLAG_UPDATE_CURRENT);
builder.setContentIntent(contentIntent);
builder.setAutoCancel(true);
builder.setLights(Color.BLUE, 500, 500);
long[] pattern = {500,500,500,500,500,500,500,500,500};
builder.setVibrate(pattern);
builder.setStyle(new NotificationCompat.InboxStyle());
// Add as notification
NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
manager.notify(1, builder.build());
Run Code Online (Sandbox Code Playgroud) 我有一个枚举:
public enum AppEnums {
SERVICE_ERROR,
CONNECTION_ERROR;
}
Run Code Online (Sandbox Code Playgroud)
我想在Android Annotation的intDef中使用它:
@IntDef({AppEnums.CONNECTION_ERROR, AppEnums.SERVICE_ERROR})
public @interface ServiceErrors {
}
Run Code Online (Sandbox Code Playgroud)
错误显示:
找到不兼容的类型,必填:'long'
我能用这种不相容的方法做些什么?
我不想手动处理AppEnum参数的值,Enum通常会自动创建值.AppEnums.CONNECTION_ERROR.ordinal()
返回enum参数的int值,但这里不起作用.
java enums android android-annotations android-support-library
我正在寻找一种在Outlook中查看CalDav日历的好方法.我知道OpenConnector项目,但到目前为止还不满意(重新:稳定性问题和配置困难).此外,它似乎得到了单个开发人员的支持,并且在大约18个月内没有新版本.
我知道Google有一个自定义Outlook插件可以连接到他们的日历(可能是通过CalDav),我知道其他Google-Outlook同步插件 - 但是还有其他选项可以将Outlook客户端连接到符合CalDav标准的通用服务器吗?
我们如何动态更改RecylerView的spanCount?
我的代码在RecyclerView中创建了3列卡片:
StaggeredGridLayoutManager mFavouratesLayoutManager;
mFavouratesLayoutManager = new StaggeredGridLayoutManager(3,
StaggeredGridLayoutManager.VERTICAL);
Run Code Online (Sandbox Code Playgroud)
我正在尝试使适配器像:
我正在 android 中启动基于 Ktor 的客户端,我想使用任何序列化器,目前是来自 kotlinx 的序列化器,但结果与其他序列化器相同 - 未找到 JsonFeature(在下面的代码片段中突出显示)。我缺少什么?
class StreamClient {
val client: HttpClient
init {
client = HttpClient(Android) {
install(JsonFeature) {
serializer = KotlinxSerializer()
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
摇篮:
implementation("io.ktor:ktor-client-core:$ktor_version")
implementation("io.ktor:ktor-client-android:$ktor_version")
implementation("io.ktor:ktor-client-serialization:$ktor_version")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.0.0")
Run Code Online (Sandbox Code Playgroud) 我正在尝试实现的是下面图像的基本和精确的复制品(我已经平方的偏好).按下首选项左侧的任何内容都应该打开一个对话框.按下togglebutton将禁用/启用我在此首选项中设置的任何内容.
我一直在努力工作几个小时,而且我空手而归.如何在PreferenceActivity中实现此功能?
编辑:似乎人们误解了我的问题.我弄清楚如何使用PreferenceActivity解决我的问题非常重要.不是活动.我不在乎我是需要用XML还是以编程方式来做.请不要向我提供我不能在类似内容中使用的答案.
编辑2:增加了赏金 - 我真的需要一个答案
我正在使用Android设计支持库,我想要一个通过滚动具有AutoHide的FloatingActionButton,
我的布局是:
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/LargeText" />
</ScrollView>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_anchorGravity="bottom|right|end"
app:layout_anchor="@id/scrollView"
android:src="@drawable/abc_btn_rating_star_off_mtrl_alpha" />
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)
FloatingActionButton总是在滚动文本时显示,我想在滚动文本时自动隐藏它.
并且,我希望通过单击FloatingActionButton来获得FloatingActionButton菜单,如下所示:
android material-design floating-action-button android-design-library
房间数据库OnConflictStrategy.ABORT
和之间有什么区别?OnConflictStrategy.IGNORE
ABORT
:冲突时回滚事务IGNORE
:保留现有行我知道当存在现有行时,他们都不会添加新行。
我已经实现了一个短信接收器,可以截获传入的短信而不会出现任何问题.但是,当我安装GO SMS Pro并设置"禁用其他消息通知"时,即使我已将意图过滤器的优先级设置得非常高,我的应用程序也不会收到任何广播消息.有没有办法克服,以便我的应用程序总是收到短信广播,无论用户在Go SMS Pro的应用程序上做什么,特别是因为我的应用程序没有显示任何UI弹出通知?一旦我卸载GO短信加强版,我的应用程序开始收到传入的短信广播,并正常工作.
这是收到传入短信并安装GO SMS Pro时的日志.GO SMS Pro有一些神奇的功能,我不明白.有人可以解释这里做了什么,我怎样才能确保我的应用每次都能得到有序的广播通知.
07-02 19:52:21.674: INFO/Zygote(25209): Zygote: pid 25209 has INTERNET permission, then set capability for CAP_NET_RAW
07-02 19:52:21.820: INFO/ActivityThread(25209): Publishing provider go-sms: com.jb.gosms.provider.GoSmsProvider
07-02 19:52:21.830: INFO/ActivityThread(25209): Publishing provider go-mms-sms: com.jb.gosms.provider.GoMmsSmsProvider
07-02 19:52:21.834: INFO/ActivityThread(25209): Publishing provider com.jb.gosms.im;com.jb.gosms.chat:
com.jb.gosms.im.database.ImContentProvider
07-02 19:52:21.842: INFO/ActivityThread(25209): Publishing provider com.jb.gosms.schedule.Schedule: com.jb.gosms.schedule.ScheduleProvider
07-02 19:52:21.846: INFO/ActivityThread(25209): Publishing provider go-mms: com.jb.gosms.provider.GoMmsProvider
07-02 19:52:21.959: DEBUG/dalvikvm(25209): GC_FOR_MALLOC freed 2657 objects / 173112 bytes in 30ms
07-02 19:52:22.182: DEBUG/dalvikvm(25209): Trying to load lib /data/data/com.jb.gosms/lib/libHanzi2Pinyin.so 0x47d4cf70 …
Run Code Online (Sandbox Code Playgroud) 我想在查询中定义和使用全局参数,因为它们在某些查询之间很常见,我有 RoleType 的全局数组:
private final static RoleType[] ROLE_TYPES = new RoleType[]{RoleType.MEMBER, RoleType.ADMIN};
Run Code Online (Sandbox Code Playgroud)
RoleType 是一个枚举,我想在查询中使用它,例如:
@Query("SELECT * FROM dialog WHERE dialog_role = " + ROLE_TYPES)
public abstract List<Dialog> getMyItems();
@Query("SELECT * FROM dialog WHERE dialog_type =:dialogType AND dialog_role = " + ROLE_TYPES)
public abstract List<Dialog> getMyItems(DialogType dialogType);
Run Code Online (Sandbox Code Playgroud)
我收到一个错误:Attribute value must be constant
。如果我将数组作为参数传递给解决的函数问题:
@Query("SELECT * FROM dialog WHERE dialog_role =:roleTypes")
public abstract List<Dialog> getMyItems(RoleType[] roleTypes);
Run Code Online (Sandbox Code Playgroud)
但我不想重复传递参数,我想在 dao 查询中处理它。
android ×9
android-room ×2
java ×2
kotlin ×2
sqlite ×2
caldav ×1
calendar ×1
enums ×1
json ×1
ktor ×1
outlook ×1
preferences ×1
togglebutton ×1