Reputation: 237
I have a share button in my app,Instead of sending app link http://play.google.com/store/apps/details?id=<package_name>
via intent ACTION_SEND
I want to link, app link in play store to a text(app name).so receiver will see a name and by clicking on that will be redirect to app in play store.How can I achive that?
SpannableString s = new SpannableString("http://play.google.com/store/apps/details?id={packageName}");
Linkify.addLinks(s, Linkify.ALL);
String messStr = "Check out this event: " + eventObj.getString(Configs.EVENTS_TITLE) + " | from #AppName "+"\n"+s +"\n";
Bitmap bitmap = ((BitmapDrawable) eImg.getDrawable()).getBitmap();
Uri uri = getImageUri(EventDetails.this, bitmap);
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("image/jpeg");
intent.putExtra(Intent.EXTRA_STREAM, uri);
intent.putExtra(Intent.EXTRA_TEXT, messStr);
startActivity(Intent.createChooser(intent, "Share on..."));
Upvotes: 1
Views: 842
Reputation: 2548
Updated Version: User change the package name
You have the button, and can set the text to whatever you want, then you set the onClick method with intent to the play store
///You need to set an EditText attribute in your layout, similar to how you set the button
packageName = (EditText) findViewById(R.id.edit);
Button button = (Button) findViewById(R.id.button_id);
//locates button from xml layout file
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// Tries to open the play store to your listing
String str = packagename.getText().toString();
try {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=" + str)));
}
catch (ActivityNotFoundException e1)
{
//catches error if play store isn't found
Toast.makeText(this, "Play Store not installed", Toast.LENGTH_SHORT).show();
}
}
});
This should work in theory.
Upvotes: 1