Create Intent to search App From Market - Android Intent

Android examples for Intent:App Market

Description

Create Intent to search App From Market

Demo Code


import android.app.SearchManager;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.widget.Toast;

public class Main{
    // ww  w.  ja v  a2  s  .c om
    public static void searchAppFromMarket(Context context,
            String packName, int notFoundError) {

        Uri uri = Uri.parse("market://search?q=pname:" + packName);
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setData(uri);
        PackageManager pManager = context.getPackageManager();
        if (intent.resolveActivity(pManager) != null)
            context.startActivity(intent);
        else {
            ToastUtils.showToast(
                    context.getResources().getString(notFoundError),
                    Toast.LENGTH_SHORT);
        }

    }
}

Related Tutorials