get More Apps by publisher name from Market - Android App

Android examples for App:App Market

Description

get More Apps by publisher name from Market

Demo Code


//package com.java2s;

import java.util.List;

import android.content.Context;

import android.content.Intent;

import android.content.pm.PackageManager;

import android.content.pm.ResolveInfo;

import android.net.Uri;
import android.widget.Toast;

public class Main {
    public static void getMoreApps(Context context, String publisherName) {
        Intent intent = new Intent(Intent.ACTION_VIEW,
                getMoreAppsUri(publisherName));

        if (isIntentAvailable(context, intent)) {
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(intent);
        } else {//from   w  w  w .j  a  v  a  2 s .c o  m
            Toast.makeText(context, "Network Error", Toast.LENGTH_LONG)
                    .show();
        }
    }

    private static Uri getMoreAppsUri(String publisherName) {
        return Uri.parse("market://search?q=pub:" + publisherName);
    }

    public static boolean isIntentAvailable(Context ctx, Intent in) {
        PackageManager packageManager = ctx.getPackageManager();
        List<ResolveInfo> activities = packageManager
                .queryIntentActivities(in, 0);
        return (activities == null) ? false : (activities.size() > 0);
    }
}

Related Tutorials