How to link to android app store

I have a free version of app and i want to link the app store on click of the buy button on the app. How to i do this, i have completely no idea and please help me with some code. Thanks in advance

what i did was `public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);

    buyButton = (Button)findViewById(R.id.buybutton);

    buyButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setData(Uri.parse("market://details?id=app name"));

Use this code to redirect user to the market:

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("market://details?id=your.game.package.name"));
startActivity(intent);

Hope this helps.


use below code

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("market://details?id=your_package_name"));
startActivity(intent);

refer this link

http://developer.android.com/guide/publishing/publishing.html


If you are in the MainActivity, you can use:

MainActivity.this.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=YourPackageName")));               

But if you are a Fragment, is important add Flag "FLAG_ACTIVITY_NEW_TASK" in your intent, like this code:

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setData(Uri.parse("market://details?id=YourPackageName"));
startActivity(intent);

if you need to know your package name, you can verify it in your manifests file

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="Here"
android:versionCode="40"
android:versionName="6.7">
链接地址: http://www.djcxy.com/p/23930.html

上一篇: 发送一条短信至多个电话号码

下一篇: 如何链接到Android应用商店