小编var*_*nkr的帖子

如何在我的应用程序中依次导航谷歌谷歌?

我正在构建一个Android应用程序,帮助用户在两点之间导航.这是doc的链接.这是我想要提供给用户的确切功能,但我希望导航发生在我的应用中,而不是通过这种方式启动意图

Uri gmmIntentUri = Uri.parse("google.navigation:q=Taronga+Zoo,+Sydney+Australia");
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
mapIntent.setPackage("com.google.android.apps.maps");
startActivity(mapIntent);
Run Code Online (Sandbox Code Playgroud)

我在我的应用程序中嵌入了谷歌地图,但无法想到如何实现此导航.有人可以指导我或提供有关相同的任何提示或教程吗?提前致谢 !!

android google-maps

5
推荐指数
1
解决办法
4489
查看次数

Hibernate Envers:发生断言失败(这可能表示Hibernate中的错误,但更可能是由于不安全地使用会话)

在我的Java应用程序中,我正在使用Hibernate Envers监听持久事件。我的侦听器类如下所示。

@Component
public class DataCreationListener extends EnversPostInsertEventListenerImpl {

    private static final long serialVersionUID = 1L;

    @Autowired
    DataService DataService;

    public DataCreationListener() {
        super(null);
    }

    @Override
    public void onPostInsert(PostInsertEvent event) {

        if (event.getEntity() instanceof DataDAO) {
            Data Data = DataService.fromDao((DataDAO) event.getEntity());
            // other stuff
        }
    }

}
Run Code Online (Sandbox Code Playgroud)

在该fromDAO方法中,我将DAO(实体类型)对象转换为api类型对象。这是fromDAO方法

@Override
    public Data fromDao(DataDAO data) {
        if (data == null) {
            return null;
        }
        Data api = new Data();
        api.setId(data.getIdUser());
        api.setAddress(data.getAddress());
        api.setCity(data.getCity());
        api.setCountry(getCountryFromId(data.getId()));

        return api;
    }
Run Code Online (Sandbox Code Playgroud)

执行时发生错误 …

java hibernate jpa hibernate-envers

5
推荐指数
1
解决办法
6574
查看次数

ShedLock:运行多个实例多次运行调度程序任务

如果服务的多个实例正在运行,我只Shedlock运行一次任务。scheduler

我遵循了文档,这就是我所做的。

这是需要定期运行的函数

@Scheduled(fixedDelayString = "300000")
@SchedulerLock(name = "onlineIngestionTask", lockAtMostFor = 240000, lockAtLeastFor = 240000)
public void pullTasksFromRemote() {
        //Code
}
Run Code Online (Sandbox Code Playgroud)

在我的配置类中,我有以下 bean

@Bean
public ScheduledLockConfiguration taskScheduler(LockProvider lockProvider) {
    return ScheduledLockConfigurationBuilder
        .withLockProvider(lockProvider)
        .withPoolSize(10)
        .withDefaultLockAtMostFor(Duration.ofMinutes(10))
        .build();
}



@Bean
public LockProvider lockProvider(DataSource dataSource) {
    return new JdbcTemplateLockProvider(dataSource);
}
Run Code Online (Sandbox Code Playgroud)

pom 包括

<dependency>
    <groupId>net.javacrumbs.shedlock</groupId>
    <artifactId>shedlock-spring</artifactId>
    <version>0.14.0</version>
</dependency>

<dependency>
    <groupId>net.javacrumbs.shedlock</groupId>
    <artifactId>shedlock-provider-jdbc-template</artifactId>
    <version>0.14.0</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)

我向数据库添加了一张表,即 jdbc 连接到的表。

CREATE TABLE shedlock(
    name VARCHAR(64), 
    lock_until TIMESTAMP(3) NULL, 
    locked_at TIMESTAMP(3) NULL, 
    locked_by  VARCHAR(255), 
    PRIMARY …
Run Code Online (Sandbox Code Playgroud)

java spring scheduled-tasks

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

MediatorLiveData onChanged没有被调用

在我的应用程序中,我尝试使用MediatorLiveData收听实时数据的更改。由于涉及数据库操作,因此我使用像这样的执行程序服务。

    MediatorLiveData<Content> mediatorLiveData = new MediatorLiveData<>();
    appExecutors.diskIO().execute(() -> {
                    long id = contentDao.insert(content);
                    Log.i("LIVE", id + "");
                    LiveData<Content> content = contentDao.getContentById(id);

                    mediatorLiveData.addSource(content, new Observer<Content>() {
                        @Override
                        public void onChanged(@Nullable Content content) {
                            Log.i("LIVE", "FIRED");
                        }
                    });

                });
Run Code Online (Sandbox Code Playgroud)

首先,我尝试将新的内容对象插入数据库。我得到插入对象的ID,该对象在下一行中登录。我得到一些很好的身份证。之后,我使用id来查询相同的对象。查询返回一个LiveData。(如果此时使用content.getValue(),则为null。

然后,我使用收听此liveData中的更改MediatorLiveData。不幸的是,从未触发mediatorLiveData的onChange方法。因此,也不会打印日志。

这是我的内容道课

@Dao
public interface ContentDao {

    @Insert
    long insert(Content content);

    @Query("SELECT * FROM my_table WHERE id = :id")
    LiveData<Content> getContentById(long id);
}
Run Code Online (Sandbox Code Playgroud)

我不明白我在做什么错。有人可以帮忙吗?谢谢!!

编辑:澄清一下,这就是代码的外观。

return new NetworkBoundResource<Content, CreateContent>(appExecutors) {
    @Override
    protected void saveCallResult(@NonNull CreateContent item) {
       //Something …
Run Code Online (Sandbox Code Playgroud)

android android-livedata android-architecture-components

5
推荐指数
1
解决办法
2175
查看次数

Android资源链接失败错误:找不到样式属性“ attr / textColorError(aka com.app.kite:attr / textColorError)”

我试图在项目中使用以下库(版本2.0.1),但是一旦尝试将其添加到gradle文件并构建项目,我就开始收到此错误。

Android resource linking failed
Output:  C:\Users\me\androidProject\kite\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:8642: error: style attribute 'attr/textColorError (aka com.app.kite:attr/textColorError)' not found.
error: failed linking references.

Command: C:\Users\me\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.1-4818971-windows.jar\355577d385562aabb3c69eea7f88a383\aapt2-3.2.1-4818971-windows\aapt2.exe link -I\
        C:\Users\me\AppData\Local\Android\Sdk\platforms\android-28\android.jar\
        --manifest\
        C:\Users\me\androidProject\kite\build\intermediates\merged_manifests\debug\processDebugManifest\merged\AndroidManifest.xml\
        -o\
        C:\Users\me\androidProject\kite\build\intermediates\processed_res\debug\processDebugResources\out\resources-debug.ap_\
        -R\
        @C:\Users\me\androidProject\kite\build\intermediates\incremental\processDebugResources\resources-list-for-resources-debug.ap_.txt\
        --auto-add-overlay\
        --java\
        C:\Users\me\androidProject\kite\build\generated\not_namespaced_r_class_sources\debug\processDebugResources\r\
        --proguard-main-dex\
        C:\Users\me\androidProject\kite\build\intermediates\legacy_multidex_aapt_derived_proguard_rules\debug\processDebugResources\manifest_keep.txt\
        --custom-package\
        com.app.kite\
        -0\
        apk\
        --output-text-symbols\
        C:\Users\me\androidProject\kite\build\intermediates\symbols\debug\R.txt\
        --no-version-vectors
Daemon:  AAPT2 aapt2-3.2.1-4818971-windows Daemon #0
Run Code Online (Sandbox Code Playgroud)

我将支持库更新为,28.0.0但是不起作用。我的编译和目标SDK版本28buildToolsVersion为28.0.3。这是我的gradle文件中的库依赖项。

implementation 'com.github.mukeshsolanki:android-otpview-pinview:2.0.1'
Run Code Online (Sandbox Code Playgroud)

有人可以帮忙吗?谢谢!!

android android-gradle-plugin

5
推荐指数
3
解决办法
2737
查看次数

插件 [id: 'com.gradle.build-scan', version: '1.16'] 未在以下任何来源中找到:

我正在尝试在我遵循此链接的 Android 项目中进行 gradle 构建扫描。

https://scans.gradle.com/

这是我的顶级 gradle 文件。

buildscript {
    ext.kotlin_version = '1.2.71'
    repositories {
        google()
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        classpath 'com.google.gms:google-services:4.2.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.firebase:firebase-plugins:1.1.5'
    }
}
plugins {
    id 'com.gradle.build-scan' version '1.16'
}
buildScan {
    licenseAgreementUrl = 'https://gradle.com/terms-of-service'
    licenseAgree = 'yes'
}
ext {
    compileSdkVersion = 27
    minSdkVersion = 16
    targetSdkVersion = 27
    zendeskSdkVersion = "2.0.0"
    appCompatVersion = "27.0.2"
}

allprojects {
    repositories {
        google()
        mavenCentral()
        jcenter()
    }
}
Run Code Online (Sandbox Code Playgroud)

当我尝试将项目与 gradle 文件同步时出现此错误

Plugin [id: …
Run Code Online (Sandbox Code Playgroud)

android android-build android-gradle-plugin

5
推荐指数
0
解决办法
6269
查看次数

Git:意外还原但未提交

嘿,看起来我很麻烦。因此,我打算使用GUI在Android Studio中提交文件,而我不小心按下了还原按钮。我的上一次提交是在4-5天之前做出的,我知道这是一种不好的做法,我应该进行更多的提交。但是我回到了5月23日的状态,我不知道该如何回到我以前的状态,事实上,这甚至还没有实现。我在这里拧吗?有希望吗?请帮助大家!

git android-studio

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

Kotlin:调用 CoroutineScope.launch 与在协程内启动之间的区别

我试图理解 Kotlin 中的结构化并发,但无法理解这段代码。

fun main(): Unit = runBlocking {
    other(this)
}

suspend fun other(scope: CoroutineScope) {
    val job = scope.launch {
        scope.launch {
            delay(200)
            println("e")
        }
        println("a")
    }
    job.invokeOnCompletion {
        println("Complete")
    }
}
Run Code Online (Sandbox Code Playgroud)

代码打印出来

a
Complete
e
Run Code Online (Sandbox Code Playgroud)

如果我用 替换内部scope.launch调用launch,就像这样

suspend fun other(scope: CoroutineScope) {
    val job = scope.launch {
       launch {
            delay(200)
            println("e")
        }
        println("a")
    }
    job.invokeOnCompletion {
        println("Complete")
    }
}
Run Code Online (Sandbox Code Playgroud)

它打印

a
e
Complete
Run Code Online (Sandbox Code Playgroud)

这表明第一个示例不遵循结构化并发,因为父作业先于子作业完成。我的困惑是,为什么会发生这种情况?

我觉得在这种情况下scope.launch可能相当于调用launch(应该相当于this.launch并且 this 指的是scope …

kotlin kotlin-coroutines coroutinescope structured-concurrency

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

查询未生成的DSL Q类类

我试图在我的eclipse maven项目中使用QueryDSL.这些是依赖项.

<properties>
        <!-- The main class to start by executing java -jar -->
        <start-class>my.app.market.DBApp</start-class>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <querydsl.version>4.1.4</querydsl.version>
        <apt-maven-plugin.version>1.1.3</apt-maven-plugin.version>

</properties>

<dependency>
            <groupId>com.querydsl</groupId>
            <artifactId>querydsl-apt</artifactId>
            <version>4.1.4</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.querydsl</groupId>
            <artifactId>querydsl-jpa</artifactId>
            <version>4.1.4</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.6.1</version>
        </dependency>

<build>
        <plugins>
            <plugin>
                <groupId>com.mysema.maven</groupId>
                <artifactId>apt-maven-plugin</artifactId>
                <version>1.1.3</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>process</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>target/generated-sources</outputDirectory>
                            <processor>com.querydsl.apt.jpa.JPAAnnotationProcessor</processor>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
Run Code Online (Sandbox Code Playgroud)

在此之后我尝试编写查询.

@Repository
public class QueryDSLRepo {

    @PersistenceContext
    private EntityManager em;

    public ReportingParamDAO save(final ReportingParamDAO reportingParamDAO) {
        em.persist(reportingParamDAO);
        return reportingParamDAO;
    }

    public List<ReportingParamDAO> findreportingParamDAOsByIdQueryDSL(final …
Run Code Online (Sandbox Code Playgroud)

java eclipse spring querydsl

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

Android:tabSelectedTextColor 不会更改 TabLayout 中选定选项卡的文本

我正在尝试更改选项卡布局中所选选项卡的文本颜色。指示器颜色工作正常,但 tabSelectedTextColor 似乎不起作用。颜色保持白色。我正在使用支持库 22.2.1,我做错了什么?有没有替代方法来实现这一目标

<android.support.design.widget.TabLayout
                android:id="@+id/tab_layout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/toolbar"
                android:elevation="6dp"
                android:minHeight="?attr/actionBarSize"
                app:tabIndicatorColor="#000000"
                app:tabSelectedTextColor="#000000"
                app:tabMode="scrollable" />
Run Code Online (Sandbox Code Playgroud)

android android-tablayout

2
推荐指数
1
解决办法
1947
查看次数