我使用新的闪屏 api 向 API 级别 23 以下的所有 Android 版本添加均匀的闪屏。对闪屏图标有任何要求吗?目前我尝试使用 svg,我认为它会在不同的屏幕上自动调整大小。有没有人也经历过这种情况并有解决方法或知道这些(隐藏的?)要求?
我使用最新的闪屏 api 版本 (1.0.0-alpha02),这是我的主题:
<style name="SplashTheme" parent="Theme.SplashScreen">
<item name="windowSplashScreenBackground">@color/colorPrimary</item>
<item name="windowSplashScreenAnimatedIcon">@drawable/ic_disney_wordmark</item>
<item name="postSplashScreenTheme">@style/AppTheme</item>
<item name="windowSplashScreenAnimationDuration">1000</item>
</style>
Run Code Online (Sandbox Code Playgroud)
这是以 ic_disney_wordmark 为例的输出,它是一个 svg:

感谢您的帮助!
我收到以下错误消息
android.content.res.Resources$NotFoundException: If the resource you are trying to use is a vector resource, you may be referencing it in an unsupported way. See AppCompatDelegate.setCompatVectorFromResourcesEnabled() for more info.
Run Code Online (Sandbox Code Playgroud)
当我试图设置以下内容时:
view.setBackgroundResource(R.drawable.highlight_background);
Run Code Online (Sandbox Code Playgroud)
要么
view.setBackgroundDrawable(ContextCompat.getDrawable(context, R.drawable.highlight_background));
Run Code Online (Sandbox Code Playgroud)
我也尝试使用AppCompatImage。这是在装有Android 4.4.4的设备上发生的。我发现了另一个StackOverflow线程,该线程可以添加
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
Run Code Online (Sandbox Code Playgroud)
进入MyApplication类,
vectorDrawables.useSupportLibrary = true
Run Code Online (Sandbox Code Playgroud)
进入build.gradle。但是错误仍然发生。可绘制对象包括以下内容:
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke android:width="2dp" android:color="?attr/colorAccent" />
</shape>
Run Code Online (Sandbox Code Playgroud)
这只是包围图像的一条线。谁能帮我?
提前致谢!
android android-support-library androiddesignsupport android-support-design android-vectordrawable
我写过单元测试,仪器测试和浓缩咖啡测试.我还使用Android Test Orchestrator运行它们以获得清晰的应用状态(对于Espresso测试非常重要).当我从Android Studio运行这些测试时,一切正常.但是当我尝试使用命令行时,我收到错误,我无法理解.
当我尝试:
./gradlew connectedAndroidTest or connectedDebugAndroidTest
Run Code Online (Sandbox Code Playgroud)
我收到:
Instrumentation run failed due to 'java.lang.IllegalStateException'
com.android.builder.testing.ConnectedDevice > No tests found.[SM-J106H -
6.0.1] FAILED
No tests found. This usually means that your test classes are not in the
form that your test runner expects (e.g. don't inherit from TestCase or lack
@Test annotations).
Run Code Online (Sandbox Code Playgroud)
当然我所有的测试都是用@Test注释的.
当我尝试
adb shell am instrument -w my.package/android.test.InstrumentationTestRunner
Run Code Online (Sandbox Code Playgroud)
我收到
INSTRUMENTATION_STATUS: Error=Unable to find instrumentation info for:
ComponentInfo{mypackage/myCustomRunner}
INSTRUMENTATION_STATUS_CODE: -1
Run Code Online (Sandbox Code Playgroud)
我使用CustomTestRunner,但错误保持不变.
当我尝试
adb shell 'CLASSPATH=$(pm path android.support.test.services) app_process …Run Code Online (Sandbox Code Playgroud) 我需要检查锁屏是否有Pin或更安全的东西(密码,指纹等).我能够检查是否有Pin,密码或模式.
KeyguardManager keyguardManager = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
return keyguardManager.isKeyguardSecure();
Run Code Online (Sandbox Code Playgroud)
我的问题是,我无法检测锁屏是否是一个模式或更低的东西.我试过这个:
int lockPatternEnable = Settings.Secure.getInt(cr, Settings.Secure.LOCK_PATTERN_ENABLED);
Run Code Online (Sandbox Code Playgroud)
但它已弃用,并引发了一个错误.我也试过这个:
long mode2 = Settings.Secure.getLong(contentResolver, "lockscreen.password_type");
Run Code Online (Sandbox Code Playgroud)
但这也以SecurityException结束.
有没有办法检测锁屏是否有针(或更高)或锁定模式或更低?KeyguardManager以这种方式对我没用:/
任何帮助表示赞赏!谢谢!
/编辑
第一个错误是:
Caused by: java.lang.SecurityException: Settings.Secure.lock_pattern_autolock is deprecated and no longer accessible. See API documentation for potential replacements.
Run Code Online (Sandbox Code Playgroud)
第二个的例外是:W/System.err:android.provider.Settings $ SettingNotFoundException:lockscreen.password_type
当您使用Marshmallow或更高版本的设备时,会出现错误(https://developer.android.com/reference/android/provider/Settings.Secure.html)