安卓(Android) 怎么开始市场审查

2019年10月17日22:08:44安卓(Android) 怎么开始市场审查已关闭评论 291 1353字阅读4分30秒

1.简介

安卓(Android) 怎么开始市场审查?——请看下文。

2.示例代码

/**
 * 版权所有 编程十万个怎么办(www.tah1986.com)
 */



import java.util.List;

import android.content.Context;

import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

import android.content.pm.PackageManager;

import android.content.pm.ResolveInfo;

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

public class Main {
    private static final String REVIEW_PREFS = "Review_pref_data";
    private static final String KEY_REVIEW_DONE = "ReviewDone";

    public static void startReview(Context context) {

        Intent intent = new Intent(Intent.ACTION_VIEW,
                getReviewUri(context));
        if (isIntentAvailable(context, intent)) {
            context.startActivity(intent);
            setReviewDone(context, true);
        } else {
            setReviewDone(context, false);
            Toast.makeText(context, "Network Error", Toast.LENGTH_LONG)
                    .show();
        }

    }

    private static Uri getReviewUri(Context context) {
        return Uri.parse("market:
    }

    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);
    }

    public static void setReviewDone(Context context, boolean isDone) {

        SharedPreferences sharedPreferences = context.getSharedPreferences(
                REVIEW_PREFS, Context.MODE_PRIVATE);
        Editor edit = sharedPreferences.edit();
        edit.putBoolean(KEY_REVIEW_DONE, isDone);
        edit.commit();

    }
}

 
继续阅读
编程十万个怎么办