簡體   English   中英

使用意圖URI啟動應用程序(並使該URI顯示為其他應用程序中的鏈接)

[英]Launch app using an intent URI (and making that URI show up as link in other apps)

我知道以前曾有人問過這個問題,我已經瀏覽了很多這樣的問題,但似乎沒有一個答案對我有用。 我想要做的是單擊鏈接時打開我的應用程序,在我看來,該鏈接看起來像點://test.com/。 我試圖通過意圖使這一工作。 當我用http://替換dots://並在方案中使用http而不是dot時,它可以正常工作。 但是由於我擁有的唯一域名的網址很長,因此走那條路不切實際。 我的Android清單如下所示:

<application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:logo="@drawable/logo"
        android:theme="@style/AppTheme" >
        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />
        <meta-data
            android:name="ADMOB_ALLOW_LOCATION_FOR_ADS"
            android:value="true" />

        <activity
            android:name="nl.delta6.dots.engine.MainActivity"
            android:exported="true"
            android:label="@string/app_name"
            android:screenOrientation="landscape"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
            <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="dots" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name="com.google.android.gms.ads.AdActivity"
            android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
</application>

我已經嘗試過諸如在Android瀏覽器中建立鏈接啟動我的應用程序之類的文章中提到的眾多解決方案 從瀏覽器鏈接啟動android應用程序 ,但似乎沒有一個對我有用。 歡迎所有想法。

編輯1:好的,所以我注意到,如果單擊網頁上的鏈接(如點鏈接),它會啟動我的應用程序。 鏈接只是不顯示為其他應用程序中的鏈接,盡管我知道這是可能的。 我會一直四處張望,但是如果有人可以將我送往正確的方向,那將是非常受歡迎的。

我認為最好的文章在這里: 在Android瀏覽器中建立鏈接以啟動我的應用程序?

請注意,您確實想使用hackbod的建議,這意味着向自己注冊方案“點”不是一個好主意。 創建瀏覽器可以使用的鏈接的最簡單方法是,首先在測試設置中將意圖格式本身轉換為uri:

Intent intent = new Intent(someContext, MainActivity.class)
System.out.println[or use logcat](intent.getUri());

然后只需將intent.getUri()的輸出粘貼為url。 它看起來像:

intent:#Intent;component=[your/activty/class/NameActivity;]

如果您將其用作網站上的鏈接,請在安裝了應用程序的手機上將其連接,然后單擊該鏈接,然后再打開您的應用程序。

請注意,如果您想查看示例意圖uri,可將其用於將多余的數據發送回您的應用程序,則還可以使用putExtra在活動中添加“附加”。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM