小编phn*_*mnn的帖子

Android 8.0:java.lang.IllegalStateException:不允许启动服务Intent

在应用程序启动时,应用程序启动应该执行某些网络任务的服务.在针对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.

" 在不允许的情况下 " - 它实际意味着什么?以及如何解决它.我不想把我的服务设置为"前景"

android android-service android-8.0-oreo

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

Android Studio 3.0错误.迁移本地模块的依赖关系配置

我最近安装了最新的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)

我读过:迁移本地模块的依赖配置

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') …
Run Code Online (Sandbox Code Playgroud)

android gradle android-studio android-studio-3.0

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

Swift项目中的导入框架,Xcode

我正在尝试导入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文件中:

迅速

import FrameworkName
Run Code Online (Sandbox Code Playgroud)

您可以使用以下语法将框架导入到不同目标中的任何Objective-C .m文件中:

Objective-C的

@import FrameworkName;
Run Code Online (Sandbox Code Playgroud)

myFramework使用Xcode 5 创建.Xcode 5没有"定义模块"构建设置.

问题出在哪儿?

xcode frameworks ios swift

47
推荐指数
3
解决办法
9万
查看次数

Android P - KeyStore异常android.os.ServiceSpecificException

如果我在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 …

java android keystore android-keystore

26
推荐指数
2
解决办法
8026
查看次数

BottomNavigationView - 如何获取所选菜单项?

我使用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)

android bottomnavigationview

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

Xcode 11-Fastlane传递失败

我正在使用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上传应用程序?

xcode fastlane

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

Android O Geofence触发延迟

我有一个使用地理围栏(创建和监控地理围栏)的导航应用程序.

谷歌说(背景位置限制):

地理围栏事件的平均响应时间是每隔几分钟左右.

以前的Android版本没有延迟.但是在Android O上,该应用程序显示在离开地理围栏后约4-5分钟的延迟(大约50%的情况).在ODP2上测试

有人遇到过类似的问题吗?

android android-geofence android-8.0-oreo

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

Xcode 11-什么是新的“背景处理”背景模式?

在XCode 11中,有一个新的后台模式“后台处理”。我找不到有关此新背景模式功能的任何信息。

后台模式功能图片

该信息是否有任何资源?此模式可以以某种方式影响在后台使用位置更新(区域监视和SLC)的应用程序吗?

xcode background-process ios ios-background-mode xcode11

6
推荐指数
3
解决办法
1266
查看次数

Android - 如何对约束布局参数进行动画处理?

我的布局如下:

<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_constraintHorizo​​ntal_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)

android android-animation android-constraintlayout

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

在混合 UIKit 和 SwiftUI 项目中,导航栏标题出现延迟

我正在展示来自 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)

标题仅在视图出现后出现。怎么修?

swiftui

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