小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

Android Instant Apps和App LInks的使用

 印度阿三17 2019-06-22

現(xiàn)在看來Android 5.0或更高版本支持Android Instant Apps.但是,App Links(我理解Instant Apps依賴)僅在6.0或更高版本中受支持.我在網上搜索過但無法找到明確的答案.

一般來說,我們希望支持即時應用程序,使用應用程序鏈接在不同功能模塊中的活動之間導航,但在大多數情況下還需要使用這些模塊來構建適用于5.0以下版本的可安裝apk
這是否意味著代碼需要檢查API級別并根據版本使用不同的方法(例如,如果< 5.0則調用具有顯式意圖的startActivity)? 這是我在Instant Apps documentation中找到的信息:

Both your instant and installable versions of your app must implement
the Android App Links feature introduced in Android 6.0. App Links
provide the primary mechanism for connecting URLs to discrete
activities within your app.

an instant app cannot launch an activity in another feature directly;
instead, it must request the URL address that corresponds to the other
other feature’s entry-point activity.

然后從https://developer./topic/instant-apps/index.html開始

Android Instant Apps supports the latest Android devices from
Android 5.0 (API level 21) through Android O

解決方法:

Android應用鏈接只是為Android系統(tǒng)提供了一種方式,可以將您的http深層鏈接與您的應用程序進行唯一關聯(lián)(無需顯示消歧對話框,供用戶選擇打開鏈接的應用程序).它沒有為您提供任何新的API來啟動活動.因此,您無論如何都需要調用startActivity.如果要打開屬于另一個即時應用程序功能模塊的活動,則只需使用隱式意圖.

對于同一功能模塊內部的導航(或者如果您的Instant App僅包含one base feature),可以自由使用明確的意圖.

It looks like right now that Android Instant Apps are supported in
Android 5.0 or later. However, App Links (which I understood that
Instant Apps depend on) are only supported in 6.0 or later

是的,這是真的.但是,即時應用程序主管(由Google Play服務內部安裝并用于在8.0之前在Android上運行即時應用程序)將確保注冊到已驗證的即時應用程序域的應用程序鏈接將直接轉發(fā)到您的即時應用程序.

Does this mean that code needs to check the API level and use
different approaches depending on version (e.g calling startActivity
if < 5.0)

是的,如果你想100%確定你的用戶不會在你的應用程序的活動之間瀏覽時顯示消歧(也就是“選擇器”)對話框like this(并且很可能你想要防止這種奇怪的用戶體驗).如果使用依賴注入,則可以在應用程序中使用用于導航的界面,然后使用可安裝和即時應用程序的不同實現(xiàn).

interface Navigation {
   void startActivityFromModuleA();
   void startActivityFromModuleB();
   …
}

class InstallableAppNavigation implements Navigation {
   public void startActivityFromModuleA() {
       // explicit intent
       Intent intent = new Intent(context, ActivityFromModuleA.class);
       context.startActivity(intent);
   }
   …
}

class InstantAppNavigation implements Navigation {
   public void startActivityFromModuleA() {
       // implicit intent
       Intent intent = new Intent(Intent.ACTION_VIEW,  
               Uri.parse("https://your./moduleA/smth"));
       context.startActivity(intent);
   }
   …
}

    本站是提供個人知識管理的網絡存儲空間,所有內容均由用戶發(fā)布,不代表本站觀點。請注意甄別內容中的聯(lián)系方式、誘導購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權內容,請點擊一鍵舉報。
    轉藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多