本文整理汇总了Java中com.github.yeriomin.playstoreapi.GooglePlayAPI类的典型用法代码示例。如果您正苦于以下问题:Java GooglePlayAPI类的具体用法?Java GooglePlayAPI怎么用?Java GooglePlayAPI使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GooglePlayAPI类属于com.github.yeriomin.playstoreapi包,在下文中一共展示了GooglePlayAPI类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getApi
import com.github.yeriomin.playstoreapi.GooglePlayAPI; //导入依赖的package包/类
GooglePlayAPI getApi() {
Properties properties = new Properties();
try {
properties.load(getClass().getClassLoader().getSystemResourceAsStream("device-gemini.properties"));
} catch (IOException e) {
halt(500, "device-gemini.properties not found");
}
PropertiesDeviceInfoProvider deviceInfoProvider = new PropertiesDeviceInfoProvider();
deviceInfoProvider.setProperties(properties);
deviceInfoProvider.setLocaleString(Locale.ENGLISH.toString());
GooglePlayAPI api = new GooglePlayAPI();
api.setClient(new OkHttpClientAdapter());
api.setDeviceInfoProvider(deviceInfoProvider);
api.setLocale(Locale.US);
return api;
}
示例2: purchase
import com.github.yeriomin.playstoreapi.GooglePlayAPI; //导入依赖的package包/类
protected void purchase(GooglePlayAPI api) {
try {
BuyResponse buyResponse = api.purchase(app.getPackageName(), app.getVersionCode(), app.getOfferType());
if (buyResponse.hasPurchaseStatusResponse()
&& buyResponse.getPurchaseStatusResponse().hasAppDeliveryData()
&& buyResponse.getPurchaseStatusResponse().getAppDeliveryData().hasDownloadUrl()
) {
deliveryData = buyResponse.getPurchaseStatusResponse().getAppDeliveryData();
}
if (buyResponse.hasDownloadToken()) {
downloadToken = buyResponse.getDownloadToken();
}
} catch (IOException e) {
Log.w(getClass().getSimpleName(), "Purchase for " + app.getPackageName() + " failed with " + e.getClass().getName() + ": " + e.getMessage());
}
}
示例3: delivery
import com.github.yeriomin.playstoreapi.GooglePlayAPI; //导入依赖的package包/类
protected void delivery(GooglePlayAPI api) throws IOException {
DeliveryResponse deliveryResponse = api.delivery(
app.getPackageName(),
shouldDownloadDelta() ? app.getInstalledVersionCode() : 0,
app.getVersionCode(),
app.getOfferType(),
GooglePlayAPI.PATCH_FORMAT.GZIPPED_GDIFF,
downloadToken
);
if (deliveryResponse.hasAppDeliveryData()
&& deliveryResponse.getAppDeliveryData().hasDownloadUrl()
) {
deliveryData = deliveryResponse.getAppDeliveryData();
} else {
throw new NotPurchasedException();
}
}
示例4: getResult
import com.github.yeriomin.playstoreapi.GooglePlayAPI; //导入依赖的package包/类
@Override
protected List<App> getResult(GooglePlayAPI api, String... packageNames) throws IOException {
super.getResult(api, packageNames);
if (!new BlackWhiteListManager(context).isUpdatable(BuildConfig.APPLICATION_ID)) {
return updatableApps;
}
int latestVersionCode = UpdaterFactory.get(context).getLatestVersionCode();
if (latestVersionCode > BuildConfig.VERSION_CODE) {
App yalp = InstalledAppsTask.getInstalledApp(context.getPackageManager(), BuildConfig.APPLICATION_ID);
if (null == yalp) {
return updatableApps;
}
yalp.setVersionCode(latestVersionCode);
yalp.setVersionName("0." + latestVersionCode);
updatableApps.add(yalp);
}
return updatableApps;
}
示例5: getResult
import com.github.yeriomin.playstoreapi.GooglePlayAPI; //导入依赖的package包/类
@Override
protected List<App> getResult(GooglePlayAPI api, String... packageNames) throws IOException {
api.toc();
Map<String, App> installedApps = getInstalledApps();
for (App appFromMarket: getAppsFromPlayStore(api, filterBlacklistedApps(installedApps).keySet())) {
String packageName = appFromMarket.getPackageName();
if (TextUtils.isEmpty(packageName) || !installedApps.containsKey(packageName)) {
continue;
}
App installedApp = installedApps.get(packageName);
appFromMarket = addInstalledAppInfo(appFromMarket, installedApp);
if (installedApp.getVersionCode() < appFromMarket.getVersionCode()) {
updatableApps.add(appFromMarket);
}
}
return updatableApps;
}
示例6: getResult
import com.github.yeriomin.playstoreapi.GooglePlayAPI; //导入依赖的package包/类
@Override
protected App getResult(GooglePlayAPI api, String... arguments) throws IOException {
DetailsResponse response = api.details(packageName);
App app = AppBuilder.build(response.getDocV2());
if (response.hasUserReview()) {
app.setUserReview(ReviewBuilder.build(response.getUserReview()));
}
PackageManager pm = context.getPackageManager();
try {
app.getPackageInfo().applicationInfo = pm.getApplicationInfo(packageName, 0);
app.getPackageInfo().versionCode = pm.getPackageInfo(packageName, 0).versionCode;
app.setInstalled(true);
} catch (PackageManager.NameNotFoundException e) {
// App is not installed
}
return app;
}
示例7: getIdTokenPairFromEmailPassword
import com.github.yeriomin.playstoreapi.GooglePlayAPI; //导入依赖的package包/类
public static Pair<String, String> getIdTokenPairFromEmailPassword(
Context context,
String email,
String password
) throws Exception {
com.github.yeriomin.playstoreapi.PlayStoreApiBuilder builder = new com.github.yeriomin.playstoreapi.PlayStoreApiBuilder()
.setHttpClient(new OkHttpClientAdapter())
.setDeviceInfoProvider(getNativeProvider(context))
.setLocale(Locale.getDefault())
.setEmail(email)
.setPassword(password);
GooglePlayAPI api = builder.build();
return new Pair<>(api.getGsfId(), api.getToken());
}
示例8: processHttpErrorCode
import com.github.yeriomin.playstoreapi.GooglePlayAPI; //导入依赖的package包/类
static private void processHttpErrorCode(int code, byte[] content) throws GooglePlayException {
if (code == 401 || code == 403) {
AuthException e = new AuthException("Auth error", code);
Map<String, String> authResponse = GooglePlayAPI.parseResponse(new String(content));
if (authResponse.containsKey("Error") && authResponse.get("Error").equals("NeedsBrowser")) {
e.setTwoFactorUrl(authResponse.get("Url"));
}
throw e;
} else if (code >= 500) {
throw new GooglePlayException("Server error", code);
} else if (code >= 400) {
throw new GooglePlayException("Malformed request", code);
}
}
示例9: getReviews
import com.github.yeriomin.playstoreapi.GooglePlayAPI; //导入依赖的package包/类
private List<Review> getReviews(String packageId, int offset, int numberOfResults) throws IOException {
List<Review> reviews = new ArrayList<>();
for (com.github.yeriomin.playstoreapi.Review review: new PlayStoreApiAuthenticator(context).getApi().reviews(
packageId,
GooglePlayAPI.REVIEW_SORT.HELPFUL,
offset,
numberOfResults
).getGetResponse().getReviewList()) {
reviews.add(ReviewBuilder.build(review));
}
return reviews;
}
示例10: build
import com.github.yeriomin.playstoreapi.GooglePlayAPI; //导入依赖的package包/类
private GooglePlayAPI build(LoginInfo loginInfo) throws IOException {
api = build(loginInfo, RETRIES);
loginInfo.setGsfId(api.getGsfId());
loginInfo.setToken(api.getToken());
save(loginInfo);
return api;
}
示例11: getRestrictionString
import com.github.yeriomin.playstoreapi.GooglePlayAPI; //导入依赖的package包/类
protected String getRestrictionString() {
switch (app.getRestriction()) {
case GooglePlayAPI.AVAILABILITY_NOT_RESTRICTED:
return null;
case GooglePlayAPI.AVAILABILITY_RESTRICTED_GEO:
return context.getString(R.string.availability_restriction_country);
case GooglePlayAPI.AVAILABILITY_INCOMPATIBLE_DEVICE_APP:
return context.getString(R.string.availability_restriction_hardware_app);
default:
return context.getString(R.string.availability_restriction_generic);
}
}
示例12: getResult
import com.github.yeriomin.playstoreapi.GooglePlayAPI; //导入依赖的package包/类
@Override
protected Void getResult(GooglePlayAPI api, String... arguments) throws IOException {
Map<String, String> topCategories = buildCategoryMap(api.categories());
manager.save(CategoryManager.TOP, topCategories);
for (String categoryId: topCategories.keySet()) {
manager.save(categoryId, buildCategoryMap(api.categories(categoryId)));
}
return null;
}
示例13: initIterator
import com.github.yeriomin.playstoreapi.GooglePlayAPI; //导入依赖的package包/类
@Override
protected AppListIterator initIterator() throws IOException {
return new AppListIterator(new CategoryAppsIterator(
new PlayStoreApiAuthenticator(context).getApi(),
categoryId,
GooglePlayAPI.SUBCATEGORY.TOP_FREE
));
}
示例14: getRemoteAppList
import com.github.yeriomin.playstoreapi.GooglePlayAPI; //导入依赖的package包/类
protected List<App> getRemoteAppList(GooglePlayAPI api, List<String> packageNames) throws IOException {
List<App> apps = new ArrayList<>();
for (BulkDetailsEntry details: api.bulkDetails(packageNames).getEntryList()) {
if (!details.hasDoc()) {
continue;
}
apps.add(AppBuilder.build(details.getDoc()));
}
Collections.sort(apps);
return apps;
}
示例15: getAppsFromPlayStore
import com.github.yeriomin.playstoreapi.GooglePlayAPI; //导入依赖的package包/类
protected List<App> getAppsFromPlayStore(GooglePlayAPI api, Collection<String> packageNames) throws IOException {
List<App> appsFromPlayStore = new ArrayList<>();
boolean builtInAccount = PreferenceActivity.getBoolean(context, PlayStoreApiAuthenticator.PREFERENCE_APP_PROVIDED_EMAIL);
for (App app: getRemoteAppList(api, new ArrayList<>(packageNames))) {
if (!builtInAccount || app.isFree()) {
appsFromPlayStore.add(app);
}
}
return appsFromPlayStore;
}