• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java FirebaseDynamicLinks类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中com.google.firebase.dynamiclinks.FirebaseDynamicLinks的典型用法代码示例。如果您正苦于以下问题:Java FirebaseDynamicLinks类的具体用法?Java FirebaseDynamicLinks怎么用?Java FirebaseDynamicLinks使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

FirebaseDynamicLinks类属于com.google.firebase.dynamiclinks包,在下文中一共展示了FirebaseDynamicLinks类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: onResume

点赞 3

import com.google.firebase.dynamiclinks.FirebaseDynamicLinks; //导入依赖的package包/类
@Override
protected void onResume() {
    super.onResume();
    if (sd != null) {
        sd.start(sensorManager);
    }
    showLoading(DataBaseHelper.getInstance().isDeviceRegistered() && presenter.isRegistration());
    FirebaseDynamicLinks.getInstance()
            .getDynamicLink(getIntent())
            .addOnSuccessListener(this, pendingDynamicLinkData -> {
                Uri deepLink = null;
                if (pendingDynamicLinkData != null) {
                    deepLink = pendingDynamicLinkData.getLink();
                }
                if (deepLink != null) {
                    presenter.onScanCompleted(deepLink.toString());
                }
            })
            .addOnFailureListener(this, e -> Log.w("TAG", "getDynamicLink:onFailure", e));
}
 

开发者ID:BANKEX,
项目名称:smart-asset-iot-android-demo,
代码行数:21,
代码来源:MainActivity.java

示例2: createShortLink

点赞 3

import com.google.firebase.dynamiclinks.FirebaseDynamicLinks; //导入依赖的package包/类
public void createShortLink() {
    // [START create_short_link]
    Task<ShortDynamicLink> shortLinkTask = FirebaseDynamicLinks.getInstance().createDynamicLink()
            .setLink(Uri.parse("https://example.com/"))
            .setDynamicLinkDomain("abc123.app.goo.gl")
            // Set parameters
            // ...
            .buildShortDynamicLink()
            .addOnCompleteListener(this, new OnCompleteListener<ShortDynamicLink>() {
                @Override
                public void onComplete(@NonNull Task<ShortDynamicLink> task) {
                    if (task.isSuccessful()) {
                        // Short link created
                        Uri shortLink = task.getResult().getShortLink();
                        Uri flowchartLink = task.getResult().getPreviewLink();
                    } else {
                        // Error
                        // ...
                    }
                }
            });
    // [END create_short_link]
}
 

开发者ID:firebase,
项目名称:snippets-android,
代码行数:24,
代码来源:MainActivity.java

示例3: shotenLongLink

点赞 3

import com.google.firebase.dynamiclinks.FirebaseDynamicLinks; //导入依赖的package包/类
public void shotenLongLink() {
    // [START shorten_long_link]
    Task<ShortDynamicLink> shortLinkTask = FirebaseDynamicLinks.getInstance().createDynamicLink()
            .setLongLink(Uri.parse("https://abc123.app.goo.gl/?link=https://example.com/&apn=com.example.android&ibn=com.example.ios"))
            .buildShortDynamicLink()
            .addOnCompleteListener(this, new OnCompleteListener<ShortDynamicLink>() {
                @Override
                public void onComplete(@NonNull Task<ShortDynamicLink> task) {
                    if (task.isSuccessful()) {
                        // Short link created
                        Uri shortLink = task.getResult().getShortLink();
                        Uri flowchartLink = task.getResult().getPreviewLink();
                    } else {
                        // Error
                        // ...
                    }
                }
            });
    // [END shorten_long_link]
}
 

开发者ID:firebase,
项目名称:snippets-android,
代码行数:21,
代码来源:MainActivity.java

示例4: buildDeepLink

点赞 3

import com.google.firebase.dynamiclinks.FirebaseDynamicLinks; //导入依赖的package包/类
/**
 * Build a Firebase Dynamic Link.
 * https://firebase.google.com/docs/dynamic-links/android/create#create-a-dynamic-link-from-parameters
 *
 * @param deepLink the deep link your app will open. This link must be a valid URL and use the
 *                 HTTP or HTTPS scheme.
 * @param minVersion the {@code versionCode} of the minimum version of your app that can open
 *                   the deep link. If the installed app is an older version, the user is taken
 *                   to the Play store to upgrade the app. Pass 0 if you do not
 *                   require a minimum version.
 * @return a {@link Uri} representing a properly formed deep link.
 */
@VisibleForTesting
public Uri buildDeepLink(@NonNull Uri deepLink, int minVersion) {
    String domain = getString(R.string.app_code) + ".app.goo.gl";

    // Set dynamic link parameters:
    //  * Domain (required)
    //  * Android Parameters (required)
    //  * Deep link
    // [START build_dynamic_link]
    DynamicLink.Builder builder = FirebaseDynamicLinks.getInstance()
            .createDynamicLink()
            .setDynamicLinkDomain(domain)
            .setAndroidParameters(new DynamicLink.AndroidParameters.Builder()
                    .setMinimumVersion(minVersion)
                    .build())
            .setLink(deepLink);

    // Build the dynamic link
    DynamicLink link = builder.buildDynamicLink();
    // [END build_dynamic_link]

    // Return the dynamic link as a URI
    return link.getUri();
}
 

开发者ID:firebase,
项目名称:quickstart-android,
代码行数:37,
代码来源:MainActivity.java

示例5: createDynamicLink_Basic

点赞 2

import com.google.firebase.dynamiclinks.FirebaseDynamicLinks; //导入依赖的package包/类
public void createDynamicLink_Basic() {
    // [START create_link_basic]
    DynamicLink dynamicLink = FirebaseDynamicLinks.getInstance().createDynamicLink()
            .setLink(Uri.parse("https://example.com/"))
            .setDynamicLinkDomain("abc123.app.goo.gl")
            // Open links with this app on Android
            .setAndroidParameters(new DynamicLink.AndroidParameters.Builder().build())
            // Open links with com.example.ios on iOS
            .setIosParameters(new DynamicLink.IosParameters.Builder("com.example.ios").build())
            .buildDynamicLink();

    Uri dynamicLinkUri = dynamicLink.getUri();
    // [END create_link_basic]
}
 

开发者ID:firebase,
项目名称:snippets-android,
代码行数:15,
代码来源:MainActivity.java

示例6: createDynamicLink_Advanced

点赞 2

import com.google.firebase.dynamiclinks.FirebaseDynamicLinks; //导入依赖的package包/类
public void createDynamicLink_Advanced() {
    // [START create_link_advanced]
    DynamicLink dynamicLink = FirebaseDynamicLinks.getInstance().createDynamicLink()
            .setLink(Uri.parse("https://example.com/"))
            .setDynamicLinkDomain("abc123.app.goo.gl")
            .setAndroidParameters(
                    new DynamicLink.AndroidParameters.Builder("com.example.android")
                            .setMinimumVersion(125)
                            .build())
            .setIosParameters(
                    new DynamicLink.IosParameters.Builder("com.example.ios")
                            .setAppStoreId("123456789")
                            .setMinimumVersion("1.0.1")
                            .build())
            .setGoogleAnalyticsParameters(
                    new DynamicLink.GoogleAnalyticsParameters.Builder()
                            .setSource("orkut")
                            .setMedium("social")
                            .setCampaign("example-promo")
                            .build())
            .setItunesConnectAnalyticsParameters(
                    new DynamicLink.ItunesConnectAnalyticsParameters.Builder()
                            .setProviderToken("123456")
                            .setCampaignToken("example-promo")
                            .build())
            .setSocialMetaTagParameters(
                    new DynamicLink.SocialMetaTagParameters.Builder()
                            .setTitle("Example of a Dynamic Link")
                            .setDescription("This link works whether the app is installed or not!")
                            .build())
            .buildDynamicLink();  // Or buildShortDynamicLink()
    // [END create_link_advanced]
}
 

开发者ID:firebase,
项目名称:snippets-android,
代码行数:34,
代码来源:MainActivity.java

示例7: testDeepLink

点赞 2

import com.google.firebase.dynamiclinks.FirebaseDynamicLinks; //导入依赖的package包/类
@Test
public void testDeepLink() {
    // Create intent to MainActivity
    Intent deepLinkIntent = new Intent(Intent.ACTION_VIEW)
        .setClassName(APP_PACKAGE, APP_PACKAGE + ".MainActivity")
        .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);


    // Load it with link information
    String deepLink = "http://example.com/12345";
    String dlDomain = mContext.getString(R.string.app_code) + ".app.goo.gl";

    DynamicLink link = FirebaseDynamicLinks.getInstance()
            .createDynamicLink()
            .setDynamicLinkDomain(dlDomain)
            .setLink(Uri.parse(deepLink))
            .buildDynamicLink();
    deepLinkIntent.setData(link.getUri());

    // Start activity
    mContext.startActivity(deepLinkIntent);

    // Check that deep link is displayed
    String deepLinkText = mContext.getString(R.string.deep_link_fmt, deepLink);
    assertTrue(mDevice.wait(Until.hasObject(By.text(deepLinkText)), UI_TIMEOUT));

    // Make sure there is an OK button, click it
    String okText = mContext.getString(android.R.string.ok);
    assertTrue(mDevice.wait(Until.hasObject(By.text(okText)), UI_TIMEOUT));
    mDevice.findObject(By.text(okText)).click();

    // Make sure that the dialog is gone
    String dialogTitleText = mContext.getString(R.string.invite_dialog_title);
    assertTrue(mDevice.wait(Until.gone(By.text(dialogTitleText)), UI_TIMEOUT));
}
 

开发者ID:firebase,
项目名称:quickstart-android,
代码行数:36,
代码来源:UiAutomatorTest.java

示例8: onCreate

点赞 2

import com.google.firebase.dynamiclinks.FirebaseDynamicLinks; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ButterKnife.bind(this);

    fillIntent(getIntent());
    fillData(getData());
    fillExtras(getExtras());

    FirebaseDynamicLinks.getInstance()
            .getDynamicLink(getIntent())
            .addOnSuccessListener(this, new OnSuccessListener<PendingDynamicLinkData>() {
                @Override
                public void onSuccess(PendingDynamicLinkData pendingDynamicLinkData) {
                    if (pendingDynamicLinkData == null) {
                        return;
                    }

                    CharSequence message = Html.fromHtml(String.format(firebaseLinkReceivedMessage, pendingDynamicLinkData.getLink()));
                    Snackbar.make(coordinatorLayout, message, Snackbar.LENGTH_INDEFINITE)
                            .addCallback(new Snackbar.Callback() {
                                @Override
                                public void onShown(Snackbar sb) {
                                    super.onShown(sb);
                                    TransitionManager.beginDelayedTransition(scrollView);
                                    snackbarSpacer.getLayoutParams().height = sb.getView().getHeight();
                                    snackbarSpacer.setVisibility(VISIBLE);
                                }

                                @Override
                                public void onDismissed(Snackbar transientBottomBar, int event) {
                                    super.onDismissed(transientBottomBar, event);
                                    TransitionManager.beginDelayedTransition(scrollView);
                                    snackbarSpacer.setVisibility(GONE);
                                }
                            })
                            .show();

                    Bundle bundle = new Bundle();
                    Bundle initialBundle = getExtras();
                    if (initialBundle != null) {
                        bundle.putAll(initialBundle);
                    }
                    // NOTE: Try to merge internal FDL extras Bundle and display it
                    Bundle firebaseBundle = pendingDynamicLinkData.zzbya();
                    if (firebaseBundle != null) {
                        bundle.putAll(firebaseBundle);
                    }
                    TransitionManager.beginDelayedTransition(scrollView);
                    fillExtras(bundle);
                }
            });
}
 

开发者ID:SimonMarquis,
项目名称:Android-App-Linking,
代码行数:55,
代码来源:MainActivity.java

示例9: onCreate

点赞 2

import com.google.firebase.dynamiclinks.FirebaseDynamicLinks; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    // [START_EXCLUDE]
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main_activity);

    // Invite button click listener
    findViewById(R.id.invite_button).setOnClickListener(this);
    // [END_EXCLUDE]

    // Check for App Invite invitations and launch deep-link activity if possible.
    // Requires that an Activity is registered in AndroidManifest.xml to handle
    // deep-link URLs.
    FirebaseDynamicLinks.getInstance().getDynamicLink(getIntent())
            .addOnSuccessListener(this, new OnSuccessListener<PendingDynamicLinkData>() {
                @Override
                public void onSuccess(PendingDynamicLinkData data) {
                    if (data == null) {
                        Log.d(TAG, "getInvitation: no data");
                        return;
                    }

                    // Get the deep link
                    Uri deepLink = data.getLink();

                    // Extract invite
                    FirebaseAppInvite invite = FirebaseAppInvite.getInvitation(data);
                    if (invite != null) {
                        String invitationId = invite.getInvitationId();
                    }

                    // Handle the deep link
                    // [START_EXCLUDE]
                    Log.d(TAG, "deepLink:" + deepLink);
                    if (deepLink != null) {
                        Intent intent = new Intent(Intent.ACTION_VIEW);
                        intent.setPackage(getPackageName());
                        intent.setData(deepLink);

                        startActivity(intent);
                    }
                    // [END_EXCLUDE]
                }
            })
            .addOnFailureListener(this, new OnFailureListener() {
                @Override
                public void onFailure(@NonNull Exception e) {
                    Log.w(TAG, "getDynamicLink:onFailure", e);
                }
            });
}
 

开发者ID:firebase,
项目名称:quickstart-android,
代码行数:52,
代码来源:MainActivity.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)