使用动态链接共享的内容未显示与打开后共享的内容相同

时间:2016-07-03 14:45:49

标签: android firebase firebase-realtime-database firebase-dynamic-links

我正在开发一个Android应用程序。有些数据是从FirebaseDatabase检索到的,并且会显示在我的应用中的RecyclerView中。

RecyclerView中有cards。在每张卡片中,都会显示图像和文字。在卡片上有一个“分享”按钮,通过点击生成dynamic-link并与任何人共享。当我点击共享的动态链接时,应用程序会打开,发生的情况是,显示了点击共享按钮的同一张卡上的图像,但始终显示上次保存的数据。我希望你明白我的观点。

以下是我如何生成dynamic-link

        Button btnShare = (Button) holder.itemView.findViewById(R.id.btn_share);
        btnShare.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                Uri BASE_URL = Uri.parse("http://www.appwebsite.com/");
                holder.APP_URI = BASE_URL.buildUpon().path(imageUIDh).build();

                packageName = holder.itemView.getContext().getPackageName();

                deepLinkTS = Uri.parse("https://u9p25.app.goo.gl/?link="+holder.APP_URI+"&apn="+packageName+"&amv="+16+"&ad="+0);

                Intent intent = new Intent(Intent.ACTION_SEND);
                intent.setType("text/plain");
                intent.putExtra(Intent.EXTRA_TEXT, "Please help this needy: " + deepLinkTS.toString() + "\n-shared through app.");

                holder.itemView.getContext().startActivity(Intent.createChooser(intent, "Share via..."));

            }
        });

以下是我在dynamic-link的{​​{1}}方法中处理onCreate()的方式:

MainActivity.class

以下是来自boolean autoLaunchDeepLink = false; AppInvite.AppInviteApi.getInvitation(mGoogleApiClient, MainActivity.this, autoLaunchDeepLink) .setResultCallback( new ResultCallback<AppInviteInvitationResult>() { @Override public void onResult(@NonNull AppInviteInvitationResult result) { if (result.getStatus().isSuccess()) { // Extract deep link from Intent Intent intent = result.getInvitationIntent(); final String deepLink = AppInviteReferral.getDeepLink(intent); // Handle the deep link. For example, open the linked // content, or apply promotional credit to the user's // account. final ProgressDialog openingSharedRequest = new ProgressDialog(MainActivity.this); openingSharedRequest.setMessage("Opening shared help-request..."); openingSharedRequest.show(); Handler handler = new Handler(); handler.postDelayed(new Runnable() { @Override public void run() { Intent helpRequestIntent = new Intent(MainActivity.this, HelpRequestThroughDeepLink.class); helpRequestIntent.putExtra("deepLink", deepLink); // helpRequestIntent.putExtra("deepLinkTS", HelpRequest.deepLinkTS.toString()); // helpRequestIntent.putExtra("APP_URI", HelpRequest.ViewHolder.APP_URI.toString()); helpRequestIntent.putExtra("postedFrom", postedFromS); // new AlertDialog.Builder(MainActivity.this) // .setMessage(deepLink) // .setPositiveButton("OK", null) // .create() // .show(); startActivity(helpRequestIntent); openingSharedRequest.dismiss(); } }, 1200); // [START_EXCLUDE] // Display deep link in the UI // ((TextView) findViewById(R.id.link_view_receive)).setText(deepLink); // [END_EXCLUDE] } else { // Log.d(TAG, "getInvitation: no deep link found."); // Toast.makeText(getBaseContext(), "Some error occurred", Toast.LENGTH_SHORT).show(); } } }); // [END get_deep_link] 的代码:

HelpRequestThroughDeepLink.java

请让我知道如何实现这一目标?

0 个答案:

没有答案