0

Currently I'm creating blog application on android. Mostly all things are done but when I'm sharing any post to Facebook or WhatsApp it shares Firebase download url, it is set by me but I want like if any user clicks on that link and if that user don't have my application then that link will redirect to play store for downloading that application, or else that post open in my application.

I search on other places but I didn't get any proper solution, If any body done this already then please help me for this.

Mr. Jay Patel
  • 37
  • 1
  • 5

2 Answers2

0

Here is the solution which will redirect to Play-store to download app

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=com.yourapp.id"));
                startActivity(intent);

If both apps are created by you and you know id and you want to open that link in your app then use this -

Intent launchIntent = getPackageManager().getLaunchIntentForPackage("com.package.address");
if (launchIntent != null) { 
startActivity(launchIntent);//null pointer check in case package name was not found
}

If you want to open link in Facebook please go through this launch facebook app from other app

VikaS GuttE
  • 1,636
  • 2
  • 14
  • 38
  • Yah I get That but how can I redirect user to my application if user already installed my application? And how can I generate that type of url? – Mr. Jay Patel Sep 30 '18 at 07:38
0

Scenario 1- if user already have your appplication then use deep linking to open your app. Take help from this official link https://developer.android.com/training/app-links/deep-linking.

Scenario 2- and if user haven't installed your app then that link will open in user's browser then handle link (can pass some parameter in link) and redirect user to play store donwload link

https://play.google.com/store/apps/details?id=your_app_package_name

you have to handle both scenarios

Neeraj Bagra
  • 134
  • 7