I've been using firebase dynamic links for my app and recently encountered the issue where when clicking on the link, instead of opening a choice view for what to use to open the app (where I can just choose my app) it's instead launching the browser first for a split second, then there's a small loading screen and then the app is launched.
This results a very unpleasant jitter that didn't happen before and I'm not sure what might suddenly cause this (I haven't changed the code). The only changes from before this issue and after is updating my phone to android version 12, and updating the gradle to use compileSdkVersion and targetSdkVersion 30.
Just in case, the code where I build the link for sending:
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND)
.setType("text/plain")
.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
// Construct dynamic link
String link = ParametersConventions.PREFIX
+ "&"
+ ParametersConventions.PARAMETER
+ "="
+ DATA
+ ParametersConventions.POSTFIX;
DynamicLink.Builder builder = FirebaseDynamicLinks.getInstance().createDynamicLink();
builder.setLink(Uri.parse(link));
builder.setAndroidParameters(new DynamicLink.AndroidParameters.Builder("com.my.package").build());
builder.setDomainUriPrefix(ParametersConventions.DOMAIN_PREFIX);
DynamicLink.SocialMetaTagParameters.Builder metaTagsBuilder = new DynamicLink.SocialMetaTagParameters.Builder();
metaTagsBuilder.setTitle("title");
metaTagsBuilder.setDescription("descp");
builder.buildShortDynamicLink().addOnSuccessListener(shortDynamicLink -> {
sendIntent.putExtra(Intent.EXTRA_TEXT, shortDynamicLink.getShortLink().toString());
Intent shareIntent = Intent.createChooser(sendIntent, null);
startActivity(shareIntent);
}).addOnFailureListener(e -> {
});
If anyone encountered it \ has an idea how I might fix it I would greatly appreciate the help. Could this be related to the fact the app isn't yet on Google appstore?
Related
I am creating a share button for a post on the feed. I am generating a unique link using Firebase Dynamic Links with a custom parameter at the end. On Android 11 and previous devices, the link was successfully handled and I retrieved the complete link and then extracted the id part from it and then loaded the correct post data using that. But on Android 12, I only get the base part of my link and not the custom parameter that I added. I don't want to change the link generation logic, since the app is already on the Play Store. Can anybody help?
Link Generation Code:
String url = "https://<BASE LINK CONFIGURED IN FIREBASE>/?link=https://<BASE LINK CONFIGURED IN FIREBASE>/&apn=<APP PACKAGE NAME>&afl=<LINK TO APP IN GOOGLE PLAY STORE>&ofl=<LINK TO APP IN GOOGLE PLAY STORE>";
Task<ShortDynamicLink> shortLinkTask = FirebaseDynamicLinks.getInstance().createDynamicLink()
.setLongLink(Uri.parse(url))
.buildShortDynamicLink()
.addOnCompleteListener(new OnCompleteListener<ShortDynamicLink>() {
#Override
public void onComplete(#NonNull Task<ShortDynamicLink> task) {
if (task.isSuccessful()) {
Uri shortLink = task.getResult().getShortLink();
String link = shortLink.toString();
link += "?id=" + post.getID();
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, link);
sendIntent.setType("text/plain");
Intent shareIntent = Intent.createChooser(sendIntent, null);
context.startActivity(shareIntent);
} else {
Toast.makeText(context, "Error creating link", Toast.LENGTH_SHORT).show();
}
}
});
Link reading code when app is opened from dynamic link:
Intent intent = getIntent();
Uri uri = intent.getData();
String uriString = uri.toString(); //Used to contain complete link, but now has only BASE LINK CONFIGURED IN FIREBASE
//Extracting parameter from complete link and further processing like fetching data etc.
Ideally I would like to not change the generation code, but if there is no other way, I guess I will have to change that. Thanks!
So, I finally solved this. Turns out this was not an Android version issue, instead for some reason it was happening only in the release APK and not the debug APK. I finally figured out what was happening. In the debug APK, I was receiving the complete link (https:///?id=), but in the release APK, I was only getting the link parameter of the original link (https:///?link=https:///&apn=&afl=&ofl=). So I added my custom generated link in this link parameter as well and it is working correctly now, both on Android 11 and 12 and on the debug APK as well as on the release APK.
I have just updated the new Uber app (January 8, 2018) and the deep linking is not working.
Could you explain more?
Below is my code:
formattedUrl = String.format("uber://action=setPickup&client_id=%s&dropoff[latitude]=%f&dropoff[longitude]=%f",
mClientId, http://to.lat , to.lng);
Uri uri = Uri.parse(formattedUrl);
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(uri);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mContext.startActivity(i);
With the old version of Uber app, my code works well. It shows the correct the pickup & drop off location but in the new app, it doesn't work.
May be they have updated things on this in their application.
You can generate deep link using this link.
My question is directly connected with this one Open Facebook page from Android app? Which answer (for the version at the moment) is not the marked one but this one
public static Intent newFacebookIntent(PackageManager pm, String url) {
Uri uri;
try {
pm.getPackageInfo("com.facebook.katana", 0);
// https://stackoverflow.com/a/24547437/1048340
uri = Uri.parse("fb://facewebmodal/f?href=" + url);
} catch (PackageManager.NameNotFoundException e) {
uri = Uri.parse(url);
}
return new Intent(Intent.ACTION_VIEW, uri);
}
Which is confirmed working last on 7th of February 2015.
My question is should you use the whole url (like www.facebook.com/mypage) or just add the url of the page so it'll be fb://facewebmodal/f?href=mypage. I tried both and it just opens the fb app without an actual page. It shows blank fb page on both tries.
Can someone give me an example with url for some public page that works?
You can try to write mypage as https://www.facebook.com/ID. The whole uri should then be
fb://facewebmodal/f?href=https://www.facebook.com/ID
and change ID to the page you want to visit.
That functionality is not documented or supported, so you may get unknown result. You may want to try passing the Page ID or Profile ID instead of names. You can get the ID by calling https://graph.facebook.com/<name> and parse the result.
I had the same issue. I searched for a while and tried all the answers on here Open facebook page from android app (in facebook version > v11) and there Open Facebook page from Android app?, finally I figured out what the real problem is. There is nothing wrong in the code, however the weird behavior is about facebook app itself. If the facebook app is on the background, it just switches back to the foreground without navigating to the requested page. You just swipe it out from the background (kill instances) and try your code again.
Considering most of the users leave facebook app on the background, this is some kind of an issue needs to be fixed. Although I think it is about the facebook app itself, somehow it can be related with the device. I'm using Nexus 6 with v 6.0.1 and had no chance to test it on another android versioned device.
i using this for my apps its working just fine, kotlin
try {
val intent = Intent(Intent.ACTION_VIEW, Uri.parse("fb://page/100674618166286"));
startActivity(intent);
} catch(e: Exception) {
startActivity( Intent(Intent.ACTION_VIEW, Uri.parse("http://www.facebook.com/iqtousd")));
}
Remember have a similar issue.
Try the mobile url :
instead of
String facebookUrl = "https://facebook.com/...";
use
String facebookUrl = "https://m.facebook.com/...";
hi everybody i've a little problem..i'm trying to share a text using google plus app, but the lastest version give me a problem.
when i call with an intent "com.google.android.apps.plus", android display me this dialog
so if i choose the first one, text will be shared correctly, but the second one do nothing.
if the app is not intalled i redirect the user to the market, at g+ download page (this work fine)
if (v == plus) {
social(2);
targetedShareIntent.putExtra(
android.content.Intent.EXTRA_TEXT, user);
targetedShareIntent
.setPackage("com.google.android.apps.plus");
startActivity(targetedShareIntent);
}
"v" is a button and social check if app is installed
any sugestion?
both options open google+ application?
I suppose show two options because google+ app have two activities with category.LAUNCHER.... the app and the chat app
PSDT: sorry for my bad english!
I was able to get the G+ dialog to launch with the following code (after querying the package manager to make sure the app was actually installed and passing in the currentContext as a parameter):
Intent appIntent = new Intent(Intent.ACTION_SEND);
String shareText = "Share text goes here";
appIntent.setType("text/plain");
appIntent.putExtra(Intent.EXTRA_TEXT, shareText);
//Filters so only the G+ app will launch
appIntent.setPackage("com.google.android.apps.plus");
try {
currentContext.startActivity(appIntent);
} catch (android.content.ActivityNotFoundException e) {
Log.d(e.getMessage());
}
Drove me bananas figuring this out, so I figured I'd try to save someone else the hassle.
I have a question related to choosing an application programmatically when shown the dialog "Complete Action Using" in Android.
An example would be as follows:
In my code, I have this statement:
startActivity(new Intent(Intent.ACTION_VIEW,
Uri.parse("http://www.youtube.com/watch?v=98yl260nMEA")));
I will then be shown a dialog box with two options:
to complete the action using the Browser or YouTube
Any idea how can I choose YouTube without being shown the dialog box?
I think you will need more information about the intent-filter of the app you want to launch by default (in this case youtube app). That target app might have multiple intent-filters and one of them might be more specific. You can call startActivity with that specific intent, and then the intended app will be launched directly. However, this requires you to have more knowledge of the target app (which is difficult in most cases like Youtube app).
Other than that, I don't think you can do much from within your app. Intent resolution is done by the Android framework, so if a user app could override it somehow, that would be a flaw in terms of security.
PackageManager pm = getPackageManager();
List<ResolveInfo> activities = pm.queryIntentActivities(new Intent(Intent.ACTION_VIEW, Uri.parse(youtube.com/watch?v=Zi_XLOBDo_Y)), 0);
Iterator<ResolveInfo> actList = activities.iterator();
while(actList.hasNext()) {
ResolveInfo curr = actList.next();
Log.d("Intents =====> ", curr.toString() + " " + curr.match + " " + curr.isDefault);
}