List of usage examples for android.app PendingIntent FLAG_NO_CREATE
int FLAG_NO_CREATE
To view the source code for android.app PendingIntent FLAG_NO_CREATE.
Click Source Link
From source file:Main.java
public static boolean alarmUp(Context context, String action) { return PendingIntent.getBroadcast(context, 0, new Intent(action), PendingIntent.FLAG_NO_CREATE) != null; }
From source file:Main.java
public static boolean hasAlarm(Context context, Intent intent, int notificationId) { return PendingIntent.getBroadcast(context, notificationId, intent, PendingIntent.FLAG_NO_CREATE) != null; }
From source file:Main.java
public static synchronized boolean isServiceAlarmOn(Context context, Intent intent, int identifier) { PendingIntent pi = PendingIntent.getService(context, identifier, intent, PendingIntent.FLAG_NO_CREATE); return pi != null; }
From source file:Main.java
public static synchronized boolean isBroadcastAlarmOn(Context context, Intent intent, int identifier) { PendingIntent pi = PendingIntent.getBroadcast(context, identifier, intent, PendingIntent.FLAG_NO_CREATE); return pi != null; }
From source file:Main.java
public static synchronized void cancelServiceAlarm(Context context, Intent intent, int identifier) { final AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); final PendingIntent pi = PendingIntent.getService(context, identifier, intent, PendingIntent.FLAG_NO_CREATE); if (pi != null) { am.cancel(pi);/*from w ww. java 2 s. c o m*/ pi.cancel(); } }
From source file:net.eledge.android.europeana.gui.fragment.HomeBlogFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mBlogAdapter = new BlogAdapter(getActivity(), new ArrayList<BlogArticle>()); BlogDownloadTask.listener = this; if (PendingIntent.getBroadcast(getActivity(), 0, new Intent(new Intent(getActivity(), BlogCheckerReceiver.class)), PendingIntent.FLAG_NO_CREATE) == null) { new BlogCheckerReceiver().enableBlogChecker(getActivity()); }/*from w ww . j ava 2 s. co m*/ }
From source file:me.oss.tracker.trackme.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); this.context = this; textView = (TextView) findViewById(R.id.deviceID); /* Handset mac*/ TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); String device_id = tm.getDeviceId(); textView.setText(device_id + ""); Intent alarm = new Intent(this.context, AlarmReceiver.class); boolean alarmRunning = (PendingIntent.getBroadcast(this.context, 0, alarm, PendingIntent.FLAG_NO_CREATE) != null); if (alarmRunning == false) { PendingIntent pendingIntent = PendingIntent.getBroadcast(this.context, 0, alarm, 0); AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE); alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime(), LocalLog.syn_time, pendingIntent); }/*from w w w. jav a 2 s . c o m*/ mRegistrationProgressBar = (ProgressBar) findViewById(R.id.registrationProgressBar); mRegistrationBroadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { mRegistrationProgressBar.setVisibility(ProgressBar.GONE); SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); boolean sentToken = sharedPreferences.getBoolean(QuickstartPreferences.SENT_TOKEN_TO_SERVER, false); if (sentToken) { mInformationTextView.setText(getString(R.string.gcm_send_message)); } else { mInformationTextView.setText(getString(R.string.token_error_message)); } } }; mInformationTextView = (TextView) findViewById(R.id.informationTextView); if (checkPlayServices()) { // Start IntentService to register this application with GCM. Intent intent = new Intent(this, RegistrationIntentService.class); startService(intent); } }
From source file:com.commonsware.android.deepbg.PollReceiver.java
static boolean doesPendingIntentExist(Context ctxt) { return (PendingIntent.getBroadcast(ctxt, 0, buildBaseIntent(ctxt), PendingIntent.FLAG_NO_CREATE) != null); }
From source file:org.chromium.ChromeAlarms.java
private void cancelAlarm(final String name) { PendingIntent pendingIntent = makePendingIntentForAlarm(name, PendingIntent.FLAG_NO_CREATE); if (pendingIntent != null) { alarmManager.cancel(pendingIntent); pendingIntent.cancel();/*from w w w . j a v a 2 s . c om*/ } }
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;/*w w w . jav a 2s . 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); } } }