小编Rob*_*ill的帖子

Android 4.2上的加密错误

以下代码适用于除最新4.2之外的所有Android版本

import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;

import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.KeyGenerator;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;

/**
 * Util class to perform encryption/decryption over strings. <br/>
 */
public final class UtilsEncryption
{
    /** The logging TAG */
    private static final String TAG = UtilsEncryption.class.getName();

    /** */
    private static final String KEY = "some_encryption_key";

    /**
     * Avoid instantiation. <br/>
     */
    private UtilsEncryption()
    {
    }

    /** The HEX characters */
    private final static String HEX = "0123456789ABCDEF"; …
Run Code Online (Sandbox Code Playgroud)

encryption android unit-testing

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

Android Maps Library V2缩放控制自定义位置

如何在GoogleMap V2中自定义内置缩放控件的位置?

对于Google地图库的第1版,有很多与此主题相关的问题.

将缩放控件放置在MapView中

如何在MapView中重新定位内置缩放控件?

如何使用setBuiltInZoomControls(true)布局缩放控件?

但是,我无法找到与库的V2有关的任何问题.

在V2中,没有方法

(LinearLayout) mapView.getZoomControls();
Run Code Online (Sandbox Code Playgroud)

所有前面提到的问题都已过时.

提前致谢

android google-maps google-maps-android-api-2

27
推荐指数
2
解决办法
2万
查看次数

Android Google Maps V2更改了我的位置图标

我在我的应用程序中使用自定义图标作为用户的当前位置,并希望在升级到新的Google地图库时保持这种方式.

使用Google Maps v1库,我扩展了MyLocationOverlay并覆盖了drawMyLocation方法以在那里绘制我的自定义图标.

谷歌地图使用setMyLocationEnabled方法启用当前位置,但据我所知,没有办法自定义它.

有谁知道如何在v2上实现这一目标?

android google-maps

17
推荐指数
2
解决办法
2万
查看次数

Android的3D地图库

有没有人知道任何具有3D功能的免费android地图库?我确定谷歌地图在使用sdk库时不支持3d.

提供商不是问题.我没有与谷歌地图结婚,也没有任何其他.

以下是可以用作我正在尝试完成的示例的应用程序.

Waze https://play.google.com/store/apps/details?id=com.waze

66号公路 https://play.google.com/store/apps/details?id=com.route66.maps5


i.stack.imgur.com/g8UXU.png

3d maps android

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

Android应用程序中的Kotlin编译器:Connection拒绝主机:127.0.0.1

我正在尝试在Docker中编译一个多模块的android应用程序(它是一个CI构建).其中一些模块包含Kotlin源代码.

构建在本地环境(MacOS)上运行良好,但由于某种原因,CI失败.

当地环境

  • MacOS 10.125.

  • java版"1.8.0_121"(Java(TM)SE运行时环境(版本1.8.0_121-b13)

CI环境

  • Docker基础映像openjdk:8-jdk

应用配置

  • Gradle Wrapper 4.0.-rc1

  • Android Build工具26

  • Kotlin版本'1.1.2-2'

  • gradle.properties(虽然我玩过所有组合并且都没有工作) org.gradle.daemon=true org.gradle.parallel=true org.gradle.jvmargs=-Xmx2048M org.gradle.configureondemand=true kotlin.compiler.execution.strategy=in-process

看起来它与某些远程进程有关,因为它无法连接到它.我想过Kotlin和Gradle deamon但是在玩了很多不同的gradle.properties配置之后,我似乎无法获得有效的配置.

warning: [options] bootstrap class path not set in conjunction with -source 1.7
Using kotlin incremental compilation
Using kotlin incremental compilation
1 warning
Compilation with Kotlin compile daemon was not successful
java.lang.IllegalStateException: Service is dying
    at org.jetbrains.kotlin.daemon.common.CompileService$CallResult$Dying.get(CompileService.kt:55)
    at org.jetbrains.kotlin.daemon.common.CompileService$CallResult$Dying.get(CompileService.kt:54)
    at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.compileWithDaemon(GradleKotlinCompilerRunner.kt:150)
    at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.compileWithDaemonOrFallback(GradleKotlinCompilerRunner.kt:112)
    at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.compileWithDaemonOrFallback(GradleKotlinCompilerRunner.kt:49)
    at org.jetbrains.kotlin.compilerRunner.KotlinCompilerRunner.runCompiler(KotlinCompilerRunner.kt:134)
    at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.runJvmCompiler(GradleKotlinCompilerRunner.kt:73)
    at org.jetbrains.kotlin.gradle.tasks.KotlinCompile.callCompiler$kotlin_gradle_plugin(Tasks.kt:259)
    at org.jetbrains.kotlin.gradle.tasks.KotlinCompile.callCompiler$kotlin_gradle_plugin(Tasks.kt:160)
    at org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile.execute(Tasks.kt:141)
    at …
Run Code Online (Sandbox Code Playgroud)

android gradle kotlin docker android-gradle-plugin

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

Kotlin在简单条件下使用

我个人喜欢when语法,因为它会使识别更加清晰.但是我担心这样做可能会引入"惩罚".

我不是字节码的专家,但我可以看到,对于相同的'逻辑',when子句需要更多的字节码操作.

具有3种不同Kotlin功能的简单文件

package com.whatever

fun method1(): String {
  return if (BuildConfig.DEBUG) "something" else "else"
}

fun method2(): String {
  return if (BuildConfig.DEBUG) {
    "something"
  } else {
    "else"
  }
}

fun method3(): String {
  return when (BuildConfig.DEBUG) {
    true -> "something"
    else -> "else"
  }
}
Run Code Online (Sandbox Code Playgroud)

生成的字节码

  // access flags 0x19
  public final static method1()Ljava/lang/String;
  @Lorg/jetbrains/annotations/NotNull;() // invisible
   L0
    LINENUMBER 4 L0
    GETSTATIC com/whatever/BuildConfig.DEBUG : Z
    IFEQ L1
    LDC "something"
    GOTO L2
   L1
    LDC "else"
   L2
    ARETURN …
Run Code Online (Sandbox Code Playgroud)

bytecode kotlin

10
推荐指数
1
解决办法
120
查看次数

Android库中的Firebase依赖关系:无法在null对象上调用方法get()

在向android库添加firebase依赖项时,我遇到了构建问题.

我的设置如下

/settings.gradle

include ':module-lib'
include ':module-app'
Run Code Online (Sandbox Code Playgroud)

/build.gradle

buildscript {
  dependencies {
    classpath 'com.android.tools.build:gradle:3.1.2'
    classpath 'com.google.gms:google-services:4.0.0'
  } 
}
Run Code Online (Sandbox Code Playgroud)

/module-lib/build.gradle

apply plugin: 'com.android.library'
android {
   ...
}
dependencies{
  api "com.google.firebase:firebase-config:16.0.0"  
}
Run Code Online (Sandbox Code Playgroud)

/module-app/build.gradle

apply plugin: 'com.android.application'
android {
   ...
}
dependencies {
  implementation project(':module-lib') 
}
apply plugin: 'com.google.gms.google-services'
Run Code Online (Sandbox Code Playgroud)

短日志:

$ ./gradlew clean build

Starting a Gradle Daemon, 1 busy and 2 stopped Daemons could not be reused, use --status for details

Parallel execution is an incubating feature.

> Configure project :module-app
Detected …
Run Code Online (Sandbox Code Playgroud)

android gradle firebase android-gradle-plugin

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

如何将 HookWidget 与 useTextEditingController 结合使用

我是颤振开发的新手,并试图了解 Riverpod。

我目前设法使以下登录表单与 StatefulWidget 一起使用。基本上,如果两个字段都不为空,则该按钮将被启用,反之亦然。

在此输入图像描述

这是它的当前代码。

import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      title: 'Login Demo',
      // theme: ThemeData(
      //   primarySwatch: Colors.blue,
      // ),
      home: Scaffold(
        body: Center(
          child: SizedBox(
            width: 400,
            child: MyLoginPage2(),
          ),
        ),
      ),
    );
  }
}

class MyLoginPage extends StatefulWidget {
  const MyLoginPage({Key? key}) : super(key: key); …
Run Code Online (Sandbox Code Playgroud)

flutter flutter-web riverpod hook-widgets

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

android locationManager在removeUpdates之后继续调用onLocationChanged

我有一个应用程序,可以获得位置修复.该应用程序将从Gingerbread推出到手机上.一旦应用程序获得位置修复,就会向用户显示Toast消息.问题是当用户移动到下一个活动时,吐司消息可能会再出现十次.

我想我已经正确地实现了生命周期,例如

1)在onCreate()中获取位置管理器2)在onResume()中创建并将位置监听器传递给管理器3)删除onStop()中的更新

我知道我可以通过调用在Android> 4.x中绕过这个问题

mlocManager.requestSingleUpdate(LocationManager.GPS_PROVIDER, mlocListener, null);
Run Code Online (Sandbox Code Playgroud)

但是我必须容纳Gingerbread所以调用单个请求不在api 2.3.x. 它在Android 4上工作正常但在姜饼上onLocationChanged方法继续执行10次.

我如何强制onLocationChanged方法只在姜饼上运行一次?

谢谢.

[编辑]我注意到,当我移动到下一个活动时,onlocationchanged方法继续执行,但如果我移动到另一个活动,则成功删除位置请求

@Override
protected void onStop() {
    mlocManager.removeUpdates(mlocListener); 
    mlocListener = null;
    super.onStop();
}

@Override
protected void onResume() {
    mlocListener = new MyLocationListener();
    if(isCompOptionsReceived == true){
        if (Build.VERSION.SDK_INT > Build.VERSION_CODES.GINGERBREAD_MR1) {
            mlocManager.requestSingleUpdate(LocationManager.GPS_PROVIDER, mlocListener, null);
        }else{
            mlocManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, mlocListener);   
        }
    }        
    super.onResume();
}

private class MyLocationListener implements LocationListener {

    @Override
    public void onLocationChanged(Location loc) {
        //toast message
    }

    @Override
    public void onProviderDisabled(String provider) {
    }

    @Override
    public void …
Run Code Online (Sandbox Code Playgroud)

gps android location

8
推荐指数
1
解决办法
6559
查看次数

Genymotion没有启动虚拟设备

我在Genymotion上创建了一个新的虚拟设备但我无法运行它.当我点击Genymotion GUI上的"开始"按钮时,没有任何反应.

在此输入图像描述

我能够从Virtual Box运行虚拟设备.虚拟设备显然配置良好,互联网正常运行.

在此输入图像描述

我目前的环境:

  • OS X 10.10.1
  • Genymotion 2.3.1
  • Virtual Box 4.3.20 r96996

值得一提的是,我最近格式化了计算机并从头开始安装了所有东西(甚至Yosemite),所以我可以错过依赖或其他东西.

任何有关如何修复它或获取日志以了解真正问题的帮助或提示将不胜感激.

谢谢

android virtualbox genymotion

8
推荐指数
1
解决办法
2258
查看次数