Example usage for android.app PendingIntent getService

List of usage examples for android.app PendingIntent getService

Introduction

In this page you can find the example usage for android.app PendingIntent getService.

Prototype

public static PendingIntent getService(Context context, int requestCode, @NonNull Intent intent,
        @Flags int flags) 

Source Link

Document

Retrieve a PendingIntent that will start a service, like calling Context#startService Context.startService() .

Usage

From source file:de.wikilab.android.friendica01.Max.java

public static void runTimer(Context c) {
    Log.i("Friendica", "try runTimer");
    if (piTimerNotifications != null)
        return;//www. ja  v  a  2  s . c  om
    AlarmManager a = (AlarmManager) c.getSystemService(Context.ALARM_SERVICE);
    piTimerNotifications = PendingIntent.getService(c, 1, new Intent(c, NotificationCheckerService.class), 0);
    a.setInexactRepeating(AlarmManager.ELAPSED_REALTIME, 0, AlarmManager.INTERVAL_FIFTEEN_MINUTES,
            piTimerNotifications);
    Toast.makeText(c, "Friendica: Notif. check timer run", Toast.LENGTH_SHORT).show();
    Log.i("Friendica", "done runTimer");
}

From source file:cc.softwarefactory.lokki.android.services.LocationService.java

private void setTemporalTimer() {
    AlarmManager alarm = (AlarmManager) getSystemService(ALARM_SERVICE);
    Intent alarmIntent = new Intent(this, LocationService.class);
    alarmIntent.putExtra(ALARM_TIMER, 1);
    PendingIntent alarmCallback = PendingIntent.getService(this, 0, alarmIntent, 0);
    alarm.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + INTERVAL_1_MIN,
            alarmCallback);// w  w  w .j a  v  a 2s.co m
    Log.e(TAG, "Time created.");
}

From source file:com.daiv.android.twitter.utils.NotificationUtils.java

public static void refreshNotification(Context context, boolean noTimeline) {
    AppSettings settings = AppSettings.getInstance(context);

    SharedPreferences sharedPrefs = context.getSharedPreferences("com.daiv.android.twitter_world_preferences",
            Context.MODE_WORLD_READABLE + Context.MODE_WORLD_WRITEABLE);
    int currentAccount = sharedPrefs.getInt("current_account", 1);

    //int[] unreadCounts = new int[] {4, 1, 2}; // for testing
    int[] unreadCounts = getUnreads(context);

    int timeline = unreadCounts[0];
    int realTimelineCount = timeline;

    // if they don't want that type of notification, simply set it to zero
    if (!settings.timelineNot || (settings.pushNotifications && settings.liveStreaming) || noTimeline) {
        unreadCounts[0] = 0;/*ww w .j a  va  2s.c o  m*/
    }
    if (!settings.mentionsNot) {
        unreadCounts[1] = 0;
    }
    if (!settings.dmsNot) {
        unreadCounts[2] = 0;
    }

    if (unreadCounts[0] == 0 && unreadCounts[1] == 0 && unreadCounts[2] == 0) {

    } else {
        Intent markRead = new Intent(context, MarkReadService.class);
        PendingIntent readPending = PendingIntent.getService(context, 0, markRead, 0);

        String shortText = getShortText(unreadCounts, context, currentAccount);
        String longText = getLongText(unreadCounts, context, currentAccount);
        // [0] is the full title and [1] is the screenname
        String[] title = getTitle(unreadCounts, context, currentAccount);
        boolean useExpanded = useExp(context);
        boolean addButton = addBtn(unreadCounts);

        if (title == null) {
            return;
        }

        Intent resultIntent;

        if (unreadCounts[1] != 0 && unreadCounts[0] == 0) {
            // it is a mention notification (could also have a direct message)
            resultIntent = new Intent(context, RedirectToMentions.class);
        } else {
            resultIntent = new Intent(context, MaterialMainActivity.class);
        }

        PendingIntent resultPendingIntent = PendingIntent.getActivity(context, 0, resultIntent, 0);

        NotificationCompat.Builder mBuilder;

        Intent deleteIntent = new Intent(context, NotificationDeleteReceiverOne.class);

        mBuilder = new NotificationCompat.Builder(context).setContentTitle(title[0])
                .setContentText(TweetLinkUtils.removeColorHtml(shortText, settings))
                .setSmallIcon(R.drawable.ic_stat_icon).setLargeIcon(getIcon(context, unreadCounts, title[1]))
                .setContentIntent(resultPendingIntent).setAutoCancel(true)
                .setTicker(TweetLinkUtils.removeColorHtml(shortText, settings))
                .setDeleteIntent(PendingIntent.getBroadcast(context, 0, deleteIntent, 0))
                .setPriority(NotificationCompat.PRIORITY_HIGH);

        if (unreadCounts[1] > 1 && unreadCounts[0] == 0 && unreadCounts[2] == 0) {
            // inbox style notification for mentions
            mBuilder.setStyle(getMentionsInboxStyle(unreadCounts[1], currentAccount, context,
                    TweetLinkUtils.removeColorHtml(shortText, settings)));
        } else if (unreadCounts[2] > 1 && unreadCounts[0] == 0 && unreadCounts[1] == 0) {
            // inbox style notification for direct messages
            mBuilder.setStyle(getDMInboxStyle(unreadCounts[1], currentAccount, context,
                    TweetLinkUtils.removeColorHtml(shortText, settings)));
        } else {
            // big text style for an unread count on timeline, mentions, and direct messages
            mBuilder.setStyle(new NotificationCompat.BigTextStyle().bigText(Html.fromHtml(
                    settings.addonTheme ? longText.replaceAll("FF8800", settings.accentColor) : longText)));
        }

        // Pebble notification
        if (sharedPrefs.getBoolean("pebble_notification", false)) {
            sendAlertToPebble(context, title[0], shortText);
        }

        // Light Flow notification
        sendToLightFlow(context, title[0], shortText);

        int homeTweets = unreadCounts[0];
        int mentionsTweets = unreadCounts[1];
        int dmTweets = unreadCounts[2];

        int newC = 0;

        if (homeTweets > 0) {
            newC++;
        }
        if (mentionsTweets > 0) {
            newC++;
        }
        if (dmTweets > 0) {
            newC++;
        }

        if (settings.notifications && newC > 0) {

            if (settings.vibrate) {
                mBuilder.setDefaults(Notification.DEFAULT_VIBRATE);
            }

            if (settings.sound) {
                try {
                    mBuilder.setSound(Uri.parse(settings.ringtone));
                } catch (Exception e) {
                    mBuilder.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));
                }
            }

            if (settings.led)
                mBuilder.setLights(0xFFFFFF, 1000, 1000);

            // Get an instance of the NotificationManager service
            NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);

            if (addButton) { // the reply and read button should be shown

                Log.v("username_for_noti", title[1]);
                sharedPrefs.edit().putString("from_notification", "@" + title[1] + " " + title[2]).commit();
                MentionsDataSource data = MentionsDataSource.getInstance(context);
                long id = data.getLastIds(currentAccount)[0];
                PendingIntent replyPending = PendingIntent.getActivity(context, 0, null, 0);
                sharedPrefs.edit().putLong("from_notification_long", id).commit();
                sharedPrefs.edit()
                        .putString("from_notification_text",
                                "@" + title[1] + ": " + TweetLinkUtils.removeColorHtml(shortText, settings))
                        .commit();

                // Create the remote input
                RemoteInput remoteInput = new RemoteInput.Builder(EXTRA_VOICE_REPLY)
                        .setLabel("@" + title[1] + " ").build();

                // Create the notification action
                NotificationCompat.Action replyAction = new NotificationCompat.Action.Builder(
                        R.drawable.ic_action_reply_dark, context.getResources().getString(R.string.noti_reply),
                        replyPending).addRemoteInput(remoteInput).build();

                NotificationCompat.Action.Builder action = new NotificationCompat.Action.Builder(
                        R.drawable.ic_action_read_dark, context.getResources().getString(R.string.mark_read),
                        readPending);

                mBuilder.addAction(replyAction);
                mBuilder.addAction(action.build());
            }

            // Build the notification and issues it with notification manager.
            notificationManager.notify(1, mBuilder.build());

            // if we want to wake the screen on a new message
            if (settings.wakeScreen) {
                PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
                final PowerManager.WakeLock wakeLock = pm.newWakeLock((PowerManager.SCREEN_BRIGHT_WAKE_LOCK
                        | PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP), "TAG");
                wakeLock.acquire(5000);
            }
        }

        // if there are unread tweets on the timeline, check them for favorite users
        if (settings.favoriteUserNotifications && realTimelineCount > 0) {
            favUsersNotification(currentAccount, context);
        }
    }

    try {

        ContentValues cv = new ContentValues();

        cv.put("tag", "com.daiv.android.twitter/com.daiv.android.twitter.ui.MainActivity");

        // add the direct messages and mentions
        cv.put("count", unreadCounts[1] + unreadCounts[2]);

        context.getContentResolver().insert(Uri.parse("content://com.teslacoilsw.notifier/unread_count"), cv);

    } catch (IllegalArgumentException ex) {

        /* Fine, TeslaUnread is not installed. */

    } catch (Exception ex) {

        /* Some other error, possibly because the format
           of the ContentValues are incorrect.
                
        Log but do not crash over this. */

        ex.printStackTrace();

    }
}

From source file:com.commonsware.android.bluetooth.rxecho.ShoutingEchoService.java

private PendingIntent buildStopPendingIntent() {
    Intent i = new Intent(this, getClass()).setAction(ACTION_STOP);

    return (PendingIntent.getService(this, 0, i, 0));
}

From source file:com.irateam.vkplayer.notifications.PlayerNotificationFactory.java

private PendingIntent createPendingIntent(String action) {
    Intent intent = new Intent(context, PlayerService.class);
    intent.setAction(action);//from  w  w w  . j av  a 2  s  .  c  om
    return PendingIntent.getService(context, 0, intent, 0);
}

From source file:com.asburymotors.android.disneysocal.service.ListenerService.java

private void showNotification(Uri attractionsUri, ArrayList<DataMap> attractions) {
    GoogleApiClient googleApiClient = new GoogleApiClient.Builder(this).addApi(Wearable.API).build();

    ConnectionResult connectionResult = googleApiClient.blockingConnect(Constants.GOOGLE_API_CLIENT_TIMEOUT_S,
            TimeUnit.SECONDS);/*  w w w.  j  a  v a 2  s.c om*/

    if (!connectionResult.isSuccess() || !googleApiClient.isConnected()) {
        Log.e(TAG, String.format(Constants.GOOGLE_API_CLIENT_ERROR_MSG, connectionResult.getErrorCode()));
        return;
    }

    Intent intent = new Intent(this, AttractionsActivity.class);
    // Pass through the data Uri as an extra
    intent.putExtra(Constants.EXTRA_ATTRACTIONS_URI, attractionsUri);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);

    int count = attractions.size();

    DataMap attraction = attractions.get(0);

    Bitmap bitmap = Utils.loadBitmapFromAsset(googleApiClient, attraction.getAsset(Constants.EXTRA_IMAGE));

    PendingIntent deletePendingIntent = PendingIntent.getService(this, 0,
            UtilityService.getClearRemoteNotificationsIntent(this), 0);

    Notification notification = new NotificationCompat.Builder(this)
            .setContentText(getResources().getQuantityString(R.plurals.attractions_found, count, count))
            .setSmallIcon(R.mipmap.ic_launcher).setDeleteIntent(deletePendingIntent)
            .addAction(new NotificationCompat.Action.Builder(R.drawable.ic_full_explore,
                    getString(R.string.action_explore), pendingIntent).build())
            .extend(new NotificationCompat.WearableExtender().setBackground(bitmap)).build();

    NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);
    notificationManager.notify(Constants.WEAR_NOTIFICATION_ID, notification);

    googleApiClient.disconnect();
}

From source file:com.fastbootmobile.encore.service.ServiceNotification.java

private void buildRemoteViews() {
    mBaseTemplate = new RemoteViews(mContext.getPackageName(), R.layout.notification_base);
    mExpandedTemplate = new RemoteViews(mContext.getPackageName(), R.layout.notification_expanded);

    // Setup pending intents
    PendingIntent piNext = PendingIntent.getService(mContext, 0, NotifActionService.getIntentNext(mContext), 0);
    PendingIntent piPrevious = PendingIntent.getService(mContext, 0,
            NotifActionService.getIntentPrevious(mContext), 0);
    PendingIntent piPause = PendingIntent.getService(mContext, 0,
            NotifActionService.getIntentTogglePause(mContext), 0);
    PendingIntent piStop = PendingIntent.getService(mContext, 0, NotifActionService.getIntentStop(mContext), 0);

    mBaseTemplate.setOnClickPendingIntent(R.id.btnNotifNext, piNext);
    mExpandedTemplate.setOnClickPendingIntent(R.id.btnNotifNext, piNext);
    mBaseTemplate.setOnClickPendingIntent(R.id.btnNotifPlayPause, piPause);
    mExpandedTemplate.setOnClickPendingIntent(R.id.btnNotifPlayPause, piPause);
    mBaseTemplate.setOnClickPendingIntent(R.id.btnNotifPrevious, piPrevious);
    mExpandedTemplate.setOnClickPendingIntent(R.id.btnNotifPrevious, piPrevious);
    mBaseTemplate.setOnClickPendingIntent(R.id.btnNotifClose, piStop);
    mExpandedTemplate.setOnClickPendingIntent(R.id.btnNotifClose, piStop);
}

From source file:com.adam.aslfms.service.ScrobblingService.java

@Override
public void onCreate() {
    settings = new AppSettings(this);
    mDb = new ScrobblesDatabase(this);
    mDb.open();/*from  w  w w  . jav  a  2  s.c  o m*/
    mNetManager = new NetworkerManager(this, mDb);

    int sdk = Build.VERSION.SDK_INT;
    if (sdk == Build.VERSION_CODES.GINGERBREAD || sdk == Build.VERSION_CODES.GINGERBREAD_MR1) {
        if (settings.isOnGoingEnabled(Util.checkPower(mCtx))) {
            if (mCurrentTrack != null) {
                String ar = mCurrentTrack.getArtist();
                String tr = mCurrentTrack.getTrack();
                String api = mCurrentTrack.getMusicAPI().readAPIname();

                // Heart intent
                Intent heartIntent = new Intent(mCtx, ScrobblingService.class);
                heartIntent.setAction(ScrobblingService.ACTION_HEART);
                PendingIntent heartPendingIntent = PendingIntent.getService(mCtx, 0, heartIntent, 0);
                NotificationCompat.Action heartAction = new NotificationCompat.Action.Builder(
                        R.mipmap.ic_status_wail_love_track, "", heartPendingIntent).build();

                Intent targetIntent = new Intent(mCtx, SettingsActivity.class);
                PendingIntent contentIntent = PendingIntent.getActivity(mCtx, 0, targetIntent,
                        PendingIntent.FLAG_UPDATE_CURRENT);
                NotificationCompat.Builder builder = new NotificationCompat.Builder(mCtx).setContentTitle(tr)
                        .setSmallIcon(R.mipmap.ic_notify).setContentText(ar + " :" + api)
                        .setPriority(NotificationCompat.PRIORITY_MIN).addAction(heartAction)
                        .setContentIntent(contentIntent);

                if (Build.VERSION.SDK_INT > Build.VERSION_CODES.HONEYCOMB_MR2) {
                    builder.setLargeIcon(
                            BitmapFactory.decodeResource(mCtx.getResources(), R.mipmap.ic_launcher));
                }

                this.startForeground(14619, builder.build());
                if (!settings.isNotifyEnabled(Util.checkPower(mCtx))) {
                    Intent iNoti = new Intent(mCtx, ForegroundHide.class);
                    this.startService(iNoti);
                }
            }
        } else {
            this.stopForeground(true); // TODO: test if this conflicts/stops scrobbles
        }
    }
}

From source file:com.piggate.samples.PiggateLoginService.Service_Notify.java

@Override
public void onTaskRemoved(Intent rootIntent) {
    Intent restartService = new Intent(getApplicationContext(), this.getClass());
    restartService.setPackage(getPackageName());
    PendingIntent restartServicePI = PendingIntent.getService(getApplicationContext(), 1, restartService,
            PendingIntent.FLAG_ONE_SHOT);
    AlarmManager alarmService = (AlarmManager) getApplicationContext().getSystemService(Context.ALARM_SERVICE);
    alarmService.set(AlarmManager.ELAPSED_REALTIME, SystemClock.elapsedRealtime() + 1000, restartServicePI);
}

From source file:com.develop.autorus.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    Fabric.with(this, new Crashlytics());
    super.onCreate(savedInstanceState);
    SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);

    AnalyticsApplication application = (AnalyticsApplication) getApplication();
    mTracker = application.getDefaultTracker();
    mTracker.setScreenName("Main activity");
    mTracker.send(new HitBuilders.ScreenViewBuilder().build());

    if (pref.getBoolean("notificationIsActive", true)) {
        Intent checkIntent = new Intent(getApplicationContext(), MonitoringWork.class);
        Boolean alrarmIsActive = false;
        if (PendingIntent.getService(getApplicationContext(), 0, checkIntent,
                PendingIntent.FLAG_NO_CREATE) != null)
            alrarmIsActive = true;//from w  w w . j  a v a2s . c  om
        am = (AlarmManager) getSystemService(ALARM_SERVICE);

        if (!alrarmIsActive) {
            Intent serviceIntent = new Intent(getApplicationContext(), MonitoringWork.class);
            PendingIntent pIntent = PendingIntent.getService(getApplicationContext(), 0, serviceIntent, 0);

            int period = pref.getInt("numberOfActiveMonitors", 0) * 180000;

            if (period != 0)
                am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + period,
                        period, pIntent);
        }
    }

    /*ForEasyDelete
            
    //Danger! Auchtung! ?, !!!
    String base64EncodedPublicKey =
        "<your license key here>";//?   . !!! ? ,    
    // github ?  .         ?!!!
            
    mHelper = new IabHelper(this, base64EncodedPublicKey);
            
    mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
    public void onIabSetupFinished(IabResult result) {
        if (!result.isSuccess()) {
            Log.d(TAG, "In-app Billing setup failed: " +
                    result);
        } else {
            Log.d(TAG, "In-app Billing is set up OK");
        }
    }
    });
    */

    //Service inapp
    Intent intent = new Intent("com.android.vending.billing.InAppBillingService.BIND");
    intent.setPackage("com.android.vending");
    blnBind = bindService(intent, mServiceConn, Context.BIND_AUTO_CREATE);

    String themeName = pref.getString("theme", "1");

    if (themeName.equals("1")) {
        setTheme(R.style.AppTheme);
        if (android.os.Build.VERSION.SDK_INT >= 21) {
            Window statusBar = getWindow();
            statusBar.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            statusBar.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            statusBar.setStatusBarColor(getResources().getColor(R.color.myPrimaryDarkColor));
        }
    } else if (themeName.equals("2")) {
        setTheme(R.style.AppTheme2);
        if (android.os.Build.VERSION.SDK_INT >= 21) {
            Window statusBar = getWindow();
            statusBar.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            statusBar.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            statusBar.setStatusBarColor(getResources().getColor(R.color.myPrimaryDarkColor2));
        }
    }
    ThemeManager.init(this, 2, 0, null);

    if (isFirstLaunch) {
        SQLiteDatabase db = new DbHelper(this).getWritableDatabase();
        Cursor cursorMonitors = db.query("monitors", null, null, null, null, null, null);
        Boolean monitorsExist = cursorMonitors != null && cursorMonitors.getCount() > 0;
        db.close();

        if (getSupportFragmentManager().findFragmentByTag("MAIN") == null) {
            FragmentTransaction fTrans = getSupportFragmentManager().beginTransaction();
            if (monitorsExist)
                mainFragment = SearchAndMonitorsFragment.newInstance(0);
            else
                mainFragment = SearchAndMonitorsFragment.newInstance(1);
            fTrans.add(R.id.container, mainFragment, "MAIN").commit();
        } else {
            mainFragment = (SearchAndMonitorsFragment) getSupportFragmentManager().findFragmentByTag("MAIN");
            if (getSupportFragmentManager().findFragmentByTag("Second") != null) {
                FragmentTransaction fTrans = getSupportFragmentManager().beginTransaction();
                fTrans.remove(getSupportFragmentManager().findFragmentByTag("Second")).commit();
            }
            pref.edit().remove("NumberOfCallingFragment");
        }
    }

    backToast = Toast.makeText(this, "?   ? ", Toast.LENGTH_SHORT);
    setContentView(R.layout.main_activity);
    mToolbar = (Toolbar) findViewById(R.id.toolbar_actionbar);
    mSnackBar = (SnackBar) findViewById(R.id.main_sn);
    setSupportActionBar(mToolbar);

    addMonitorButton = (Button) findViewById(R.id.toolbar_add_monitor_button);

    mNavigationDrawerFragment = (NavigationDrawerFragment) getSupportFragmentManager()
            .findFragmentById(R.id.fragment_drawer);
    mNavigationDrawerFragment.setup(R.id.fragment_drawer, (DrawerLayout) findViewById(R.id.drawer), mToolbar);

    Thread threadAvito = new Thread(new Runnable() {
        @TargetApi(Build.VERSION_CODES.HONEYCOMB)
        public void run() {
            Document doc;
            SharedPreferences sPref;
            try {
                String packageName = getApplicationContext().getPackageName();
                doc = Jsoup.connect("https://play.google.com/store/apps/details?id=" + packageName).userAgent(
                        "Mozilla/5.0 (Windows; U; WindowsNT 5.1; ru-RU; rv1.8.1.6) Gecko/20070725 Firefox/2.0.0.6")
                        .timeout(12000).get();
                //"")

                PackageManager packageManager;
                PackageInfo packageInfo;
                packageManager = getPackageManager();

                packageInfo = packageManager.getPackageInfo(getPackageName(), 0);
                Element mainElems = doc.select(
                        "#body-content > div > div > div.main-content > div.details-wrapper.apps-secondary-color > div > div.details-section-contents > div:nth-child(4) > div.content")
                        .first();

                if (!packageInfo.versionName.equals(mainElems.text())) {
                    sPref = getPreferences(MODE_PRIVATE);
                    SharedPreferences.Editor ed = sPref.edit();
                    ed.putBoolean(SAVED_TEXT_WITH_VERSION, false);
                    ed.commit();
                } else {
                    sPref = getPreferences(MODE_PRIVATE);
                    SharedPreferences.Editor ed = sPref.edit();
                    ed.putBoolean(SAVED_TEXT_WITH_VERSION, true);
                    ed.commit();

                }
                //SharedPreferences sPrefRemind;
                //sPrefRemind = getPreferences(MODE_PRIVATE);
                //sPrefRemind.edit().putBoolean(DO_NOT_REMIND, false).commit();
            } catch (HttpStatusException e) {
                return;
            } catch (IOException e) {
                return;
            } catch (PackageManager.NameNotFoundException e) {

                e.printStackTrace();
            }
        }
    });

    SharedPreferences sPrefVersion;
    sPrefVersion = getPreferences(MODE_PRIVATE);
    Boolean isNewVersion;
    isNewVersion = sPrefVersion.getBoolean(SAVED_TEXT_WITH_VERSION, true);

    threadAvito.start();
    boolean remind = true;
    if (!isNewVersion) {
        Log.d("affa", "isNewVersion= " + isNewVersion);
        SharedPreferences sPref12;
        sPref12 = getPreferences(MODE_PRIVATE);
        String isNewVersion12;

        PackageManager packageManager;
        PackageInfo packageInfo;
        packageManager = getPackageManager();

        try {
            packageInfo = packageManager.getPackageInfo(getPackageName(), 0);
            isNewVersion12 = sPref12.getString("OldVersionName", packageInfo.versionName);

            if (!isNewVersion12.equals(packageInfo.versionName)) {
                SharedPreferences sPref;
                sPref = getPreferences(MODE_PRIVATE);
                SharedPreferences.Editor ed = sPref.edit();
                ed.putBoolean(SAVED_TEXT_WITH_VERSION, false);
                ed.commit();

                SharedPreferences sPrefRemind;
                sPrefRemind = getPreferences(MODE_PRIVATE);
                sPrefRemind.edit().putBoolean(DO_NOT_REMIND, false).commit();
            } else
                remind = false;

            SharedPreferences sPrefRemind;
            sPrefRemind = getPreferences(MODE_PRIVATE);
            sPrefRemind.edit().putString("OldVersionName", packageInfo.versionName).commit();
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }

        SharedPreferences sPrefRemind;
        sPrefRemind = getPreferences(MODE_PRIVATE);
        Boolean dontRemind;
        dontRemind = sPrefRemind.getBoolean(DO_NOT_REMIND, false);
        Log.d("affa", "dontRemind= " + dontRemind.toString());
        Log.d("affa", "remind= " + remind);
        Log.d("affa", "44444444444444444444444= ");
        if ((!dontRemind) && (!remind)) {
            Log.d("affa", "5555555555555555555555555= ");
            SimpleDialog.Builder builder = new SimpleDialog.Builder(R.style.SimpleDialogLight) {
                @Override
                public void onPositiveActionClicked(DialogFragment fragment) {
                    super.onPositiveActionClicked(fragment);
                    String packageName = getApplicationContext().getPackageName();
                    Intent intent = new Intent(Intent.ACTION_VIEW,
                            Uri.parse("https://play.google.com/store/apps/details?id=" + packageName));
                    startActivity(intent);
                }

                @Override
                public void onNegativeActionClicked(DialogFragment fragment) {
                    super.onNegativeActionClicked(fragment);
                }

                @Override
                public void onNeutralActionClicked(DialogFragment fragment) {
                    super.onNegativeActionClicked(fragment);
                    SharedPreferences sPrefRemind;
                    sPrefRemind = getPreferences(MODE_PRIVATE);
                    sPrefRemind.edit().putBoolean(DO_NOT_REMIND, true).commit();
                }
            };

            builder.message(
                    "  ??   ? ? ?")
                    .title(" !").positiveAction("")
                    .negativeAction("").neutralAction("? ");
            DialogFragment fragment = DialogFragment.newInstance(builder);
            fragment.show(getSupportFragmentManager(), null);
        }
    }
}