List of usage examples for android.content Intent ACTION_TIME_TICK
String ACTION_TIME_TICK
To view the source code for android.content Intent ACTION_TIME_TICK.
Click Source Link
From source file:com.kncwallet.wallet.service.BlockchainServiceImpl.java
@Override public void onCreate() { serviceCreatedAt = System.currentTimeMillis(); log.debug(".onCreate()"); super.onCreate(); nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); final String lockName = getPackageName() + " blockchain sync"; final PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, lockName); application = (WalletApplication) getApplication(); prefs = PreferenceManager.getDefaultSharedPreferences(this); final Wallet wallet = application.getWallet(); bestChainHeightEver = prefs.getInt(Constants.PREFS_KEY_BEST_CHAIN_HEIGHT_EVER, 0); peerConnectivityListener = new PeerConnectivityListener(); sendBroadcastPeerState(0);/* w w w .j av a 2 s . c o m*/ final IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); intentFilter.addAction(Intent.ACTION_DEVICE_STORAGE_LOW); intentFilter.addAction(Intent.ACTION_DEVICE_STORAGE_OK); registerReceiver(connectivityReceiver, intentFilter); blockChainFile = new File(getDir("blockstore", Context.MODE_PRIVATE), Constants.BLOCKCHAIN_FILENAME); final boolean blockChainFileExists = blockChainFile.exists(); if (!blockChainFileExists) { log.info("blockchain does not exist, resetting wallet"); wallet.clearTransactions(0); wallet.setLastBlockSeenHeight(-1); // magic value wallet.setLastBlockSeenHash(null); } try { blockStore = new SPVBlockStore(Constants.NETWORK_PARAMETERS, blockChainFile); blockStore.getChainHead(); // detect corruptions as early as possible final long earliestKeyCreationTime = wallet.getEarliestKeyCreationTime(); if (!blockChainFileExists && earliestKeyCreationTime > 0) { try { final InputStream checkpointsInputStream = getAssets().open(Constants.CHECKPOINTS_FILENAME); CheckpointManager.checkpoint(Constants.NETWORK_PARAMETERS, checkpointsInputStream, blockStore, earliestKeyCreationTime); } catch (final IOException x) { log.error("problem reading checkpoints, continuing without", x); } } } catch (final BlockStoreException x) { blockChainFile.delete(); final String msg = "blockstore cannot be created"; log.error(msg, x); throw new Error(msg, x); } log.info("using " + blockStore.getClass().getName()); try { blockChain = new BlockChain(Constants.NETWORK_PARAMETERS, wallet, blockStore); } catch (final BlockStoreException x) { throw new Error("blockchain cannot be created", x); } application.getWallet().addEventListener(walletEventListener); registerReceiver(tickReceiver, new IntentFilter(Intent.ACTION_TIME_TICK)); maybeRotateKeys(); }
From source file:com.hamradiocoin.wallet.service.BlockchainServiceImpl.java
@Override public void onCreate() { serviceCreatedAt = System.currentTimeMillis(); log.debug(".onCreate()"); super.onCreate(); nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); final String lockName = getPackageName() + " blockchain sync"; final PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, lockName); application = (WalletApplication) getApplication(); config = application.getConfiguration(); final Wallet wallet = application.getWallet(); bestChainHeightEver = config.getBestChainHeightEver(); peerConnectivityListener = new PeerConnectivityListener(); sendBroadcastPeerState(0);/*from w w w. ja va2s. c o m*/ final IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); intentFilter.addAction(Intent.ACTION_DEVICE_STORAGE_LOW); intentFilter.addAction(Intent.ACTION_DEVICE_STORAGE_OK); registerReceiver(connectivityReceiver, intentFilter); blockChainFile = new File(getDir("blockstore", Context.MODE_PRIVATE), Constants.Files.BLOCKCHAIN_FILENAME); final boolean blockChainFileExists = blockChainFile.exists(); if (!blockChainFileExists) { log.info("blockchain does not exist, resetting wallet"); wallet.clearTransactions(0); wallet.setLastBlockSeenHeight(-1); // magic value wallet.setLastBlockSeenHash(null); } try { blockStore = new SPVBlockStore(Constants.NETWORK_PARAMETERS, blockChainFile); blockStore.getChainHead(); // detect corruptions as early as possible final long earliestKeyCreationTime = wallet.getEarliestKeyCreationTime(); if (!blockChainFileExists && earliestKeyCreationTime > 0) { try { final InputStream checkpointsInputStream = getAssets() .open(Constants.Files.CHECKPOINTS_FILENAME); CheckpointManager.checkpoint(Constants.NETWORK_PARAMETERS, checkpointsInputStream, blockStore, earliestKeyCreationTime); } catch (final IOException x) { log.error("problem reading checkpoints, continuing without", x); } } } catch (final BlockStoreException x) { blockChainFile.delete(); final String msg = "blockstore cannot be created"; log.error(msg, x); throw new Error(msg, x); } log.info("using " + blockStore.getClass().getName()); try { blockChain = new BlockChain(Constants.NETWORK_PARAMETERS, wallet, blockStore); } catch (final BlockStoreException x) { throw new Error("blockchain cannot be created", x); } application.getWallet().addEventListener(walletEventListener, Threading.SAME_THREAD); registerReceiver(tickReceiver, new IntentFilter(Intent.ACTION_TIME_TICK)); maybeRotateKeys(); }
From source file:cc.mintcoin.wallet.service.BlockchainServiceImpl.java
private void startBlockChain() { if (blockChain != null) return;/*from w ww. j ava 2 s. c om*/ final Wallet wallet = application.getWallet(); final String lockName = getPackageName() + " blockchain sync"; final PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, lockName); peerConnectivityListener = new PeerConnectivityListener(); sendBroadcastPeerState(0); final IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); intentFilter.addAction(Intent.ACTION_DEVICE_STORAGE_LOW); intentFilter.addAction(Intent.ACTION_DEVICE_STORAGE_OK); registerReceiver(connectivityReceiver, intentFilter); boolean blockChainFileExists = blockChainFile.exists(); if (!blockChainFileExists) { log.info("blockchain does not exist, resetting wallet"); wallet.clearTransactions(0); wallet.setLastBlockSeenHeight(-1); // magic value wallet.setLastBlockSeenHash(null); } try { blockStore = new TxTrackingBlockStore(Constants.NETWORK_PARAMETERS, blockChainFile); blockStore.getChainHead(); // detect corruptions as early as possible final long earliestKeyCreationTime = wallet.getEarliestKeyCreationTime(); } catch (final BlockStoreException x) { deleteBlockChainFile(); final String msg = "blockstore cannot be created"; log.error(msg, x); throw new Error(msg, x); } log.info("using " + blockStore.getClass().getName()); try { blockChain = new TxTrackingBlockChain(Constants.NETWORK_PARAMETERS, wallet, blockStore); } catch (final BlockStoreException x) { throw new Error("blockchain cannot be created", x); } application.getWallet().addEventListener(walletEventListener, Threading.SAME_THREAD); registerReceiver(tickReceiver, new IntentFilter(Intent.ACTION_TIME_TICK)); maybeRotateKeys(); return; }
From source file:com.eveningoutpost.dexdrip.Home.java
@Override protected void onResume() { xdrip.checkForcedEnglish(xdrip.getAppContext()); super.onResume(); checkEula();/*from w w w .j a v a 2 s . c o m*/ set_is_follower(); _broadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context ctx, Intent intent) { if (intent.getAction().compareTo(Intent.ACTION_TIME_TICK) == 0) { updateCurrentBgInfo("time tick"); } } }; newDataReceiver = new BroadcastReceiver() { @Override public void onReceive(Context ctx, Intent intent) { holdViewport.set(0, 0, 0, 0); updateCurrentBgInfo("new data"); } }; registerReceiver(_broadcastReceiver, new IntentFilter(Intent.ACTION_TIME_TICK)); registerReceiver(newDataReceiver, new IntentFilter(Intents.ACTION_NEW_BG_ESTIMATE_NO_DATA)); holdViewport.set(0, 0, 0, 0); if (invalidateMenu) { invalidateOptionsMenu(); invalidateMenu = false; } activityVisible = true; updateCurrentBgInfo("generic on resume"); if (!JoH.getWifiSleepPolicyNever()) { if (JoH.ratelimit("policy-never", 3600)) { if (getPreferencesLong("wifi_warning_never", 0) == 0) { if (!JoH.isMobileDataOrEthernetConnected()) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("WiFi Sleep Policy Issue"); builder.setMessage( "Your WiFi is set to sleep when the phone screen is off.\n\nThis may cause problems if you don't have cellular data or have devices on your local network.\n\nWould you like to go to the settings page to set:\n\nAlways Keep WiFi on during Sleep?"); builder.setNeutralButton("Maybe Later", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builder.setPositiveButton("YES, Do it", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); toast("Recommend that you change WiFi to always be on during sleep"); startActivity(new Intent(Settings.ACTION_WIFI_IP_SETTINGS)); } }); builder.setNegativeButton("NO, Never", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); setPreferencesLong("wifi_warning_never", (long) JoH.ts()); } }); AlertDialog alert = builder.create(); alert.show(); } } } } if (NFCReaderX.useNFC()) { NFCReaderX.doNFC(this); } else { NFCReaderX.disableNFC(this); } if (get_follower() || get_master()) { GcmActivity.checkSync(this); } }