Reputation: 117
I have published an app and now I want to update it . I am trying to add a button to direct the users to my another app on Google Play. I will suggest my users to download my another app if they like the current one. I found this code and added to my code in onCreate method.
button.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v)
{
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("market://HTTPS://details?id=com.example.android"));
startActivity(intent);
}
});
I wrote the xml part and button definiton too. There is nothing wrong with them. I wrote my application's package name instead of com.example.android. Emulator crashes because there is no Googleplay in it. I tried this on my android device. It crashes too and I don't have any logcat for this. Can you suggest any other methods to give market link to my users ?(It should Directly open my application on google play , it should not visit the website)
P.S : I edited the code and it works. Here in case if anyone needs it.
button.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v)
{
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("market://details?id=com.example.android"));
startActivity(intent);
}
});
Upvotes: 0
Views: 131
Reputation: 14398
Try this
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("market://details?id=com.example.android"));
startActivity(intent);
Upvotes: 1