Back to project page Android-MarketBin.
The source code is released under:
MIT License
If you think the Android project Android-MarketBin listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.haunted.marketbin; /*from w ww.j a v a2s. c om*/ import android.content.Context; import android.content.Intent; import android.net.Uri; import android.text.Html; import android.text.method.LinkMovementMethod; import android.widget.TextView; import org.jetbrains.annotations.NotNull; public class MarketUI { public static void bindAppLink(@NotNull TextView view, @NotNull IMarketDescriptor marketDescriptor, @NotNull String packageName) { String displayName = marketDescriptor.getMarketName(); if (marketDescriptor.getIntentFormat() == null) throw new NullPointerException("MarketDescriptor.intentFormat == null for " + displayName); String url = String.format(marketDescriptor.getIntentFormat(), packageName); String href = String.format("<a href='%s'>%s</a>", url, displayName); view.setText(Html.fromHtml(href)); view.setMovementMethod(LinkMovementMethod.getInstance()); } public static void showAppInMarket(@NotNull Context context, @NotNull IMarketDescriptor marketDescriptor, @NotNull String packageName) { String url = String.format(marketDescriptor.getIntentFormat(), packageName); Intent appIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); context.startActivity(appIntent); } }