从Chrome启动活动时出现运行时异常

时间:2019-03-07 09:57:07

标签: android

我已配置我的应用程序中的一项活动,可以使用如下所示的深层链接将其打开:

<activity
        android:name=".ui.barcodescanner.BarcodeScannerActivity"
        android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data
                android:host="com.company"
                android:scheme="http"
                android:pathPrefix="/myapp"/>
        </intent-filter>
    </activity>

当chrome在API 27 Pixel 2 XL仿真器上重定向到http://com.mycompany/myap时,此操作可以正常工作(我的应用程序以正确的活动启动)。但是,当我在API 29 OnePlus 6上运行它时,出现以下错误:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.company.android.myapp/com.company.android.myapp.ui.login.IONLoginActivity}: android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity  context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3037)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3172)
    at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1906)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:193)
    at android.app.ActivityThread.main(ActivityThread.java:6863)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:537)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
 Caused by: android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity  context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
    at android.app.ContextImpl.startActivity(ContextImpl.java:915)
    at android.app.ContextImpl.startActivity(ContextImpl.java:891)
    at android.content.ContextWrapper.startActivity(ContextWrapper.java:379)
    at com.infor.authentication.AuthenticationManager.loadWebView(AuthenticationManager.java:712)
    at com.infor.authentication.AuthenticationManager.showAuthenticationDialog(AuthenticationManager.java:1810)
    at com.infor.authentication.AuthenticationManager.validateValuesAndStoreValues(AuthenticationManager.java:512)
    at com.infor.authentication.AuthenticationManager.initiateAuthentication(AuthenticationManager.java:460)
    at com.company.android.myapp.ui.login.IONLoginViewModel.authenticateWithION(IONLoginViewModel.java:26)
    at com.company.android.myapp.ui.login.IONLoginActivity.onCreate(IONLoginActivity.java:36)
    at android.app.Activity.performCreate(Activity.java:7149)
    at android.app.Activity.performCreate(Activity.java:7140)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1288)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3017)

这是为什么?

0 个答案:

没有答案
相关问题