小编Jon*_* S.的帖子

如何在SQLite WHERE子句中包含布尔值

我没有结果.如何where在SQLite 中的子句中包含布尔条件?

我试过这些

"Select * from table where col = 1"
"Select * from table where col = '1'"
"Select * from table where col = true"
"Select * from table where col = 'true'"
"Select * from table where col = 'True'"
"Select * from table where col is True"
Run Code Online (Sandbox Code Playgroud)

没有.我甚至尝试在查询函数中包含"true"作为whereArgs.

我该如何解决?

sqlite android

11
推荐指数
1
解决办法
1万
查看次数

确定mediaplayer的opencore或stagefright框架?

我需要确定媒体播放器是否正在使用opencore媒体框架,以便我可以禁用搜索我的流.opencore框架看起来似乎无法通过搜索失败,我很难相信他们允许投入生产,但看起来仍然如此.

我希望它就像确定他们的SDK版本一样简单,但是api 8的droid手机似乎仍然使用opencore,所以似乎不是一个好的选择.有任何想法吗?

编辑:

在耶稣的回应之后,我想出了这段代码.到目前为止,它似乎在我的测试中运行良好.如果有人不认为这是寻求溪流的合理方法,请告诉我

    if (Build.VERSION.SDK_INT < 8) //2.1 or earlier, opencore only, no stream seeking
        mStreamSeekable = false;
    else { // 2.2, check to see if stagefright enabled
        mStreamSeekable = false;
        try {
                FileInputStream buildIs = new FileInputStream(new File("/system/build.prop"));
                if (CloudUtils.inputStreamToString(buildIs).contains("media.stagefright.enable-player=true"))
                    mStreamSeekable = true;
            } catch (IOException e) { //problem finding build file
                e.printStackTrace();
            }
        }
    } 
Run Code Online (Sandbox Code Playgroud)

android media-player

9
推荐指数
1
解决办法
9809
查看次数

下载线程中的PARTIAL_WAKE_LOCK与SCREEN_DIM_WAKE_LOCK

我有一个服务,它产生一个下载线程,有时下载大文件.我意识到,一旦手机进入睡眠状态,下载线程就会显着减慢,然后停止.

一个明显的补救措施,一个唤醒锁.所以我认为可以获得一个partial_wake_lock,只是为了让cpu处理下载.但这不起作用,相同的行为,下载速度减慢,然后在屏幕关闭时停止.

然后我尝试了screen_dim_wake_lock.这一次,屏幕保持打开(变暗),下载保持全速,直到完成,唤醒锁定,然后电话睡觉.

我的问题是,为什么我不能保持我的线程运行时,像在screen_dim_wake_lock期间一样持有partial_wake_lock?关于这两者之间的区别是否存在一些无证的行为?是因为我不是在UI线程上运行吗?

编辑:

我添加了一个wifilock.wifi没有进入睡眠状态,但我的线程仍然死亡.如果某个其他进程唤醒系统,则下载将以正常速度继续,然后再次减速.如果我唤醒手机,它将以正常速度继续,而不是在屏幕熄灭时再次减速.似乎线程被系统推入后台.我想知道我是否可以阻止这一点.

service multithreading android download wakelock

9
推荐指数
1
解决办法
3672
查看次数

在三星安卓上禁用listview overscroll

我需要完全禁用listview中的过度滚动,这样我就可以实现自己的过度滚动功能.

看一下核心listview类似乎很简单,只需将过卷模式设置为OVERSCROLL_NEVER即可.这对我的三星Galaxy s2没有任何作用.我也试图覆盖overScrollBy函数什么都不做.这也行不通.

有没有人对三星ListView自定义有很多经验可以帮助我?

android listview scroll

7
推荐指数
1
解决办法
4048
查看次数

CollapsingToolbarLayout扩展无法与RecyclerView一起使用

CollapsibleToolbarLayout关于RecyclerView的行为似乎已被破坏.为...设置值时

应用:layout_scrollFlags

如果不使用"scroll | enterAlways",则Colbsible布局将永远不会展开.它总会收缩,但是当你拉下来时,它不会再展开,所以它只会被锁定在顶部.

如果您使用"scroll | enterAlways",它会按预期工作,这意味着每当您向下滚动时,它会立即将标题扩展到其完整高度.

在不知情的情况下,似乎可折叠布局无法正确确定RecyclerView何时位于列表顶部,因为这是在其他情况下何时应扩展到全高的标准.

这是我正在测试的布局.java代码并不重要,它只是使用虚拟数据和使用LinearLayoutManager填充recyclerview.

<?xml version="1.0" encoding="utf-8"?>

<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">

<android.support.v7.widget.RecyclerView
    android:id="@+id/recycler_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior" />

<android.support.design.widget.AppBarLayout
    android:id="@+id/appbar"
    android:layout_width="match_parent"
    android:layout_height="200dp"
    android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
    android:fitsSystemWindows="true">

    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/collapsing_toolbar"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true"
        app:toolbarId="@id/toolbar_id"
        app:contentScrim="@color/white"
        app:layout_scrollFlags="scroll|exitUntilCollapsed">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar_id"
            android:layout_width="match_parent"
            android:layout_height="?android:attr/actionBarSize"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
            app:layout_collapseMode="pin"/>

    </android.support.design.widget.CollapsingToolbarLayout>

</android.support.design.widget.AppBarLayout>

</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)

android android-support-library material-design android-design-library android-collapsingtoolbarlayout

4
推荐指数
1
解决办法
5844
查看次数

在java中用条件测试getType的子类

我必须找出方法返回类型是否是某个基类的子类.到目前为止,我找不到内置的方法来做到这一点,我只能找到一种方法来测试一个完全的类匹配.我也可以使用注释来做到这一点,但我的想法是,如果我碰巧添加一个新的子类,我不想添加额外的代码.我想过对所有可能的子类进行测试,或者创建一个无类型的对象并使用"instanceof"测试它的实例,但似乎没有什么是理想的.理想的情况是:

if (m.getReturnType() Extends Superclass.class)
Run Code Online (Sandbox Code Playgroud)

但是没有"扩展"功能类似于"instanceof"与实际实例.是否有一个我不知道的条件运算符?提前感谢您的任何想法.

这实际上是一个Android项目,所以我可能无法实现所有可能性.

java conditional android

3
推荐指数
1
解决办法
157
查看次数