gpt4 book ai didi

android - 在另一个应用程序 Android 中启动一个应用程序

转载 作者:行者123 更新时间:2023-11-29 02:33:14 25 4
gpt4 key购买 nike

我的问题是如何在应用程序 B 中启动应用程序 A,使应用程序 A 通过深度链接在应用程序 B 中?

在下面的第一张图片中,Debug 应用显示为独立于 Slack 的应用(新代码,Firebase 深层链接)。在第二张图片中,Debug 应用似乎在 Slack 应用中(旧代码,Android 深度链接)。我想使用 Firebase 深层链接并在其他应用程序(Slack、Gmail 等)中显示调试应用程序。

enter image description here enter image description here

任何人都可以通过下面的代码让我知道如何实现吗?

旧代码,Android 深度链接:

AndroidManifest

<activity
android:name=".activity.SplashScreenActivity"
android:screenOrientation="portrait"
android:theme="@style/SplashTheme">
<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" />
<!-- Accepts URIs that begin with "abc://flights” -->
<data
android:host="sales"
android:scheme="abc" />
<data
android:host="deals"
android:scheme="abc" />
</intent-filter>
</activity>

Activity :

Intent intent = new Intent(SplashScreenActivity.this, BottomNavBarActivity.class);

        //Deep Linking Content
Uri deepLinkData = getIntent().getData();
if (deepLinkData != null) {
intent.putExtra(EXTRA_DEEP_LINK, deepLinkData.getHost());
}

startActivity(intent);
overridePendingTransition(R.anim.splash_fade_in, R.anim.splash_fade_out);
finish();

新代码,Firebase 深层链接:

安卓 list :

<activity
android:name=".activity.SplashScreenActivity"
android:screenOrientation="portrait"
android:theme="@style/SplashTheme">
<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:host="abc.app.goo.gl"
android:scheme="http"/>
<data
android:host="abc.app.goo.gl"
android:scheme="https"/>
</intent-filter>
</activity>

Activity :

FirebaseDynamicLinks.getInstance()
.getDynamicLink(getIntent())
.addOnSuccessListener(this, new OnSuccessListener<PendingDynamicLinkData>() {
@Override
public void onSuccess(PendingDynamicLinkData pendingDynamicLinkData) {
// Get deep link from result (may be null if no link is found)
Uri deepLink = null;
if (pendingDynamicLinkData != null) {

// Start the activity through intent, same as before.

}
}
})
.addOnFailureListener(this, new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Log.v(TAG, "Firebase deep link failure");
}
});

最佳答案

它取决于发送 Intent 的应用程序,例如它们是否通过了 FLAG_ACTIVITY_NEW_TASK。我怀疑这里的区别在于 Slack 处理链接的方式 - 他们可能会以不同于其他格式的方式处理 Web URL(您的旧链接具有非标准方案)。

关于android - 在另一个应用程序 Android 中启动一个应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48493908/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com