-1

I want to share a text in any messaging app as plain text. On clicking this text: the user will navigate to the application if present otherwise it will take it to play store. I am new in android, Please help me out of this. Thanks in advance

2 Answers2

0

You can share the text, but the power to handle that is not in your hands, since you don't have any authority over the third party application which handles the text.

Yauraw Gadav
  • 1,706
  • 1
  • 18
  • 39
0

You need to do like this on click of your text

final String appPackageName = "com..."; /*this is the package name you want to redirect application*/
                try {
                    Toast.makeText(MainActivity.this, "Application is already insatlled", Toast.LENGTH_LONG).show();
                    startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName)));
                    finish();
                } catch (android.content.ActivityNotFoundException anfe) {
                    Toast.makeText(SplashActivity.this, "Redirecting to your app on playstore", Toast.LENGTH_LONG).show();
                    startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + appPackageName)));
                    finish();
                }
R7G
  • 1,000
  • 1
  • 10
  • 15