Android Google Play Uygulama Puanlama

package com.mobilhanem.rateandroidapp;

 

import android.content.ActivityNotFoundException;

import android.content.Context;

import android.content.Intent;

import android.content.SharedPreferences;

import android.net.Uri;

import android.support.annotation.NonNull;

 

import com.afollestad.materialdialogs.DialogAction;

import com.afollestad.materialdialogs.MaterialDialog;

import com.github.javiersantos.materialstyleddialogs.MaterialStyledDialog;

 

import java.text.SimpleDateFormat;

import java.util.Calendar;

 

 

/**

* Created by alper 10 15/12/16.

*/

 

public class AppRating {

 

    private son static String APP_PNAME = “com.uniapps.unitiraf”;// Paket Adi

 

    public static void app_launched(Context mContext) {

        SharedPreferences prefs = mContext.getSharedPreferences(“apprater”, );

        if (prefs.getBoolean(“dontshowagain”, false)) { return ; }

 

        SharedPreferences.Editor editor = prefs.edit();

 

        long launch_count = prefs.getLong(“launch_count”, ) + 1;

        editor.putLong(“launch_count”, launch_count);

 

        int runCount = prefs.getInt(“count”,) + 1;

        editor.putInt(“count”,runCount);

 

        SharedPreferences datePrefs = mContext.getSharedPreferences(“SharedPrefDate”, );

        SimpleDateFormat dfDate  = new SimpleDateFormat(“dd/MM/yyyy”);

 

        Calendar cal = Calendar.getInstance();

        java.util.Date newDateVal = null;

        java.util.Date oldDateVal = null;

        try {

            newDateVal = dfDate.parse(dfDate.format(cal.getTime()));

            oldDateVal = dfDate.parse(datePrefs.getString(“dateVal”,“”));

        } catch (java.text.ParseException e) {

            e.printStackTrace();

        }

 

 

        int diffInDays = (int) ((newDateVal.getTime()   oldDateVal.getTime())/ (1000 * 60 * 60 * 24));

        System.out.println(“date”+diffInDays);

 

        if(diffInDays>=2){

 

            if(runCount%2==){

                SharedPreferences dateShared = mContext.getSharedPreferences(“SharedPrefDate”, );

                SharedPreferences.Editor dateEditor  = dateShared.edit();

                Calendar today = Calendar.getInstance();

                dateEditor.putString(“dateVal”,dfDate.format(today.getTime()));

                dateEditor.commit();

                showRateDialog(mContext, editor);

            }

 

Daha fazla gör:  Java Paket Yapısı ve Import Kavramı | Java Dersleri

        }

 

        editor.commit();

 

    }

 

    public static void showRateDialog(son Context mContext, son SharedPreferences.Editor editor) {

 

 

        new MaterialStyledDialog.Builder(mContext)

                .setTitle(“Puan Ver!”)

                .setDescription(“Eğer uygulamayı beğendiyseniz tatmin etmek kredi notu verin!”)

                .setCancelable(false)

                .setNegativeText(“Hayır, Teşekkürler”)

                .onNegative(new MaterialDialog.SingleButtonCallback() {

                    @Override

                    public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {

 

                        if (editor != null) {

                            editor.putBoolean(“dontshowagain”, true);

                            editor.commit();

                        }

                    }

                })

                .setNeutralText(“Daha Sonra”)

                .onNeutral(new MaterialDialog.SingleButtonCallback() {

                    @Override

                    public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {

 

                        SharedPreferences prefs = mContext.getSharedPreferences(“apprater”, );

                        SharedPreferences.Editor editor = prefs.edit();

                        editor.putInt(“count”,);

                        editor.commit();

 

                    }

                })

                .setIcon(R.drawable.mobilhanem_logo)

                .withIconAnimation(true)

                .setPositiveText(“Puan Ver”)

                .onPositive(new MaterialDialog.SingleButtonCallback() {

                    @Override

                    public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {

 

                        Uri uri = Uri.parse(“market://details?id=” + APP_PNAME);

                        Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri);

                        goToMarket.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY |

                                Intent.FLAG_ACTIVITY_NEW_DOCUMENT |

                                Intent.FLAG_ACTIVITY_MULTIPLE_TASK);

                        try {

                            mContext.startActivity(goToMarket);

                        } catch (ActivityNotFoundException e) {

                            mContext.startActivity(new Intent(Intent.ACTION_VIEW,

                                    Uri.parse(“http://play.google.com/store/apps/details?id=” + APP_PNAME)));

                        }

                    }

                })

                .show();

 

    }

}

Gönderiyi görüyorsun: Android Google Play Uygulama Puanlama

Kaynak: https://lorenzolesite.com

Kategori: teknoloji

Leave a Reply