在应用程序启动时,应用程序启动应该执行某些网络任务的服务.在针对API级别26后,我的应用程序无法在后台启动Android 8.0上的服务.
引起:java.lang.IllegalStateException:不允许启动服务Intent {cmp = my.app.tt/com.my.service}:app在后台uid UidRecord {90372b1 u0a136 CEM空闲过程:1 seq(0,0) ,0)}
据我所知,它涉及: 后台执行限制
如果针对Android 8.0的应用程序在不允许创建后台服务的情况下尝试使用该方法,则startService()方法现在会抛出IllegalStateException.
" 在不允许的情况下 " - 它实际意味着什么?以及如何解决它.我不想把我的服务设置为"前景"
我最近安装了最新的Canary版本的Android Studio,目前正在使用Android Gradle插件3.0.0-alpha4.
我现在得到一个错误:
Error:Failed to resolve: Could not resolve project :MyLib.
Required by:
project :app
Run Code Online (Sandbox Code Playgroud)
我读过:迁移本地模块的依赖配置
Run Code Online (Sandbox Code Playgroud)dependencies { // This is the old method and no longer works for local // library modules: // debugCompile project(path: ':foo', configuration: 'debug') // releaseCompile project(path: ':foo', configuration: 'release') // Instead, simply use the following to take advantage of // variant-aware dependency resolution. You can learn more about // the 'implementation' configuration in the section about // new dependency configurations. implementation project(':foo') …
我正在尝试导入myFramework项目.我myFramework在Build Phases-> Link Binary With Libraries中添加了.
Objective-c的工作原理:
#import <UIKit/UIKit.h>
#import <myFramework/myFramework.h>
Run Code Online (Sandbox Code Playgroud)
但是在Swift中,我收到一个No such module myFramework错误:
import UIKit
import myFramework
Run Code Online (Sandbox Code Playgroud)
根据Swift文档:
导入外部框架
您可以导入具有纯Objective-C代码库,纯Swift代码库或混合语言代码库的外部框架.无论框架是用单一语言编写还是包含来自两种语言的文件,导入外部框架的过程都是相同的.导入外部框架时,请确保将要导入的框架的"定义模块"构建设置设置为"是".
您可以使用以下语法将框架导入到不同目标中的任何Swift文件中:
迅速
Run Code Online (Sandbox Code Playgroud)import FrameworkName您可以使用以下语法将框架导入到不同目标中的任何Objective-C .m文件中:
Objective-C的
Run Code Online (Sandbox Code Playgroud)@import FrameworkName;
我myFramework使用Xcode 5 创建.Xcode 5没有"定义模块"构建设置.
问题出在哪儿?
如果我在Android P上运行此代码,我会收到以下异常:
private static KeyStore.PrivateKeyEntry getPrivateKeyEntry(String alias) {
try {
KeyStore ks = KeyStore
.getInstance(SecurityConstants.KEYSTORE_PROVIDER_ANDROID_KEYSTORE);
ks.load(null);
KeyStore.Entry entry = ks.getEntry(alias, null);
if (entry == null) {
Log.w(TAG, "No key found under alias: " + alias);
Log.w(TAG, "Exiting signData()...");
return null;
}
if (!(entry instanceof KeyStore.PrivateKeyEntry)) {
Log.w(TAG, "Not an instance of a PrivateKeyEntry");
Log.w(TAG, "Exiting signData()...");
return null;
}
return (KeyStore.PrivateKeyEntry) entry;
} catch (Exception e) {
Log.e(TAG, e.getMessage(), e);
return null;
}
}
Run Code Online (Sandbox Code Playgroud)
例外:
在android.os.Parcel.readException的android.os.Parcel.readException(Parcel.java:1910)的android.os.Parcel.createException(Parcel.java:1956)上的KeyStore异常android.os.ServiceSpecificException :(代码7) (Parcel.java:1860)位于android.security.keynd.KandStoreStoreSpi的android.security.IKeystoreService $ Stub …
我使用BottomNavigationView来切换片段.如何获取当前选中的菜单项,以防止重新打开片段?
BottomNavigationView bottomNavigationView = (BottomNavigationView)
findViewById(R.id.bottom_navigation);
bottomNavigationView.setOnNavigationItemSelectedListener(
new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
switch (item.getItemId()) {
case R.id.action_1:
// open fragment 1
break;
case R.id.action_2:
// open fragment 2
break;
case R.id.action_3:
// open fragment 3
break;
}
return false;
}
});
}
Run Code Online (Sandbox Code Playgroud) 我正在使用fastlane将二进制文件上传到App Store Connect。我需要使用Xcode 11构建我的应用程序,但无法将其上传到App Store Connect。错误:
[12:20:49]:在/Applications/Xcode-beta.app/Contents/Developer/上找不到传输程序。请确保为Xcode安装设置了正确的路径。
Xcode 11不再包含Transporter应用程序。
如何使用fastlane和xcode 11上传应用程序?
我的布局如下:
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
...
<FrameLayout
android:id="@+id/wrapper"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintHorizontal_bias=".5"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:padding="@dimen/glow">
</FrameLayout>
</android.support.constraint.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)
我如何制作应用程序:layout_constraintHorizontal_bias 参数的动画?
我试过:
ValueAnimator animation = ValueAnimator.ofFloat(0f, 1f);
animation.setDuration(1000);
animation.start();
animation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator updatedAnimation) {
float animatedValue = (float)updatedAnimation.getAnimatedValue();
ConstraintLayout.LayoutParams constraintLayoutParams = (ConstraintLayout.LayoutParams) mAvatarWrapper.getLayoutParams();
constraintLayoutParams.horizontalBias = animatedValue;
}
});
Run Code Online (Sandbox Code Playgroud)
或者 :
public class ResizeAnimation extends Animation {
View view;
float horizontalBias;
public ResizeAnimation(View view, float horizontalBias) {
this.view = view;
this.horizontalBias = horizontalBias;
}
@Override
protected void applyTransformation(float interpolatedTime, …Run Code Online (Sandbox Code Playgroud) 我正在展示来自 UIViewController 的 SwiftUI 视图。
let vc = UIHostingController(rootView: SwiftUIView())
navigationController?.pushViewController(vc, animated: true)
struct SwiftUIView: View {
var body: some View {
VStack {
}
.navigationBarTitle("Title")
}
}
Run Code Online (Sandbox Code Playgroud)
标题仅在视图出现后出现。怎么修?