如果我尝试注册一个文件associaton应用程序挂在启动 [英] If I try to register a file associaton the app hangs at the start

查看:234
本文介绍了如果我尝试注册一个文件associaton应用程序挂在启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我曾尝试注册使用这个问题

我想打开主活动的应用程序,如果用户试图打开已注册的文件类型

I want to open the main Activity of the app if the user try to open the registered file type

。根据在清单接受的答案我已经试过这code

According the accepted answer in the Manifest I have tried this code

<activity
            android:name=".MainActivity"
            android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <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:scheme="http" android:host="*"
                    android:pathPattern=".*\\.myfilextension" />
                <data android:scheme="https" android:host="*"
                    android:pathPattern=".*\\.myfilextension" />
                <data android:scheme="content" android:host="*"
                    android:pathPattern=".*\\.myfilextension" />
                <data android:scheme="file" android:host="*"
                    android:pathPattern=".*\\.myfilextension" />
            </intent-filter>
        </activity>

.myfilextension 似乎不正确有关,因为如果我试图打开一个文件 sample.myfilextension 什么发生的情况。

but the .myfilextension seems not correctly associated, since if I try to open a file sample.myfilextension nothing happens.

所以,我曾尝试

<activity
            android:name=".MainActivity"
            android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <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:scheme="http" />
            <data android:scheme="https" />
            <data android:scheme="ftp" />
            <data android:scheme="file" />
            <data android:host="*" />
            <data android:mimeType="*/*" />
            <data android:pathPattern=".*\\.myfilextension" />
       </intent-filter>
</activity>

有了这个code,如果我尝试打开一个文件 .myfilextension 和App已经启动,并在后台一切运转正常工作,但如果应用程序被关闭,当我尝试打开该文件,应用程序试图启动,但挂起,在模拟器挂起的等待调试器的SOI无法理解的问题的原因。

With this code, if I try to open a file .myfilextension and the App has been launched and is running in background everything works fine, but if the app is closed when I try to open the file, the app try to start but hangs, in the emulator hangs on "wait for debugger" soI cannot understand the cause of the issue.

我怎么能解决这个问题?

How could I fix this?

推荐答案

第二个示例code应该工作。

The second sample code should work.

在模拟器上挂起等待调试器

in the emulator hangs on "wait for debugger"

这个问题似乎涉及到不能附加调试仿真器。

The problem seems related to the Emulator that cannot attach the debugger.

试着按以下步骤操作:

-close模拟器

依序前往AVD管理器并重新重新模拟器

-Go to AVD manager and recreate the emulator again

- 启动模拟器并尝试运行应用程序

-Start the emulator and try to run the app

或者尝试运行在真实设备上的应用程序。

Alternatively try to run the app on a real device.

这篇关于如果我尝试注册一个文件associaton应用程序挂在启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆