开发者

Launch always my app instead of see the action chooser?

开发者 https://www.devze.com 2023-03-16 15:12 出处:网络
i have one activity with the same intent filters than other application. Soo when i run my app, i have to choose which action i want to be performed but i dont wanna choose this.

i have one activity with the same intent filters than other application. Soo when i run my app, i have to choose which action i want to be performed but i dont wanna choose this.

I always want to run my application with high priority and dont show the action chooser. Any idea for make 开发者_运维知识库this? thanks


I always want to run my application with high priority and dont show the action chooser. Any idea for make this?

The user can elect to do this by checking the "make this the default" checkbox at the bottom of the chooser dialog.

You, as a developer, cannot unilaterally make yourself the default.

My activity reads a tags NFC but how android have already installed other NFC app with the same intent filter i dont know any solution.

Your filter says that you want to handle all tags. If that is true, then the user will have to choose whether to make your app the default.

However, you can make a tighter filter and take priority. For example:

<activity android:name="URLHandler" android:label="@string/app_name">
    <intent-filter android:label="@string/app_name">
        <action android:name="android.nfc.action.NDEF_DISCOVERED" />
        <data android:scheme="http"
                    android:host="commonsware.com"
                    android:path="/nfctest"
        />
        <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
</activity>

Here, my activity will get control if (and only if) the tag has an NDEF record that results in a URL of http://commonsware.com/nfctest. Since my filter has tighter scope than other competing applications, mine will get control without a chooser.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号