Example usage for android.content Intent ACTION_TIME_TICK

List of usage examples for android.content Intent ACTION_TIME_TICK

Introduction

In this page you can find the example usage for android.content Intent ACTION_TIME_TICK.

Prototype

String ACTION_TIME_TICK

To view the source code for android.content Intent ACTION_TIME_TICK.

Click Source Link

Document

Broadcast Action: The current time has changed.

Usage

From source file:com.slushpupie.deskclock.DeskClock.java

public DeskClock() {
    super();//ww w. j  ava2 s  .  c  om
    // determine if multitouch is really supported
    try {
        getXMethod = MotionEvent.class.getMethod("getX", new Class[] { int.class });
        getYMethod = MotionEvent.class.getMethod("getY", new Class[] { int.class });
        supportMultiTouch = true;
    } catch (NoSuchMethodException nsme) {
        supportMultiTouch = false;
    }

    intentReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            String action = intent.getAction();

            if (Intent.ACTION_DOCK_EVENT.equals(action)) {
                int dockState = intent.getIntExtra(Intent.EXTRA_DOCK_STATE, 0);
                switch (dockState) {
                case Intent.EXTRA_DOCK_STATE_UNDOCKED:
                    Log.d(LOG_TAG, "received EXTRA_DOCK_STATE_UNDOCKED");
                    if (prefsUndockExit)
                        finish();
                    else
                        Log.d(LOG_TAG, "Ignoring...");
                    break;
                case Intent.EXTRA_DOCK_STATE_DESK:
                    Log.d(LOG_TAG, "received EXTRA_DOCK_STATE_DESK");
                    break;
                }
            }
            if (Intent.ACTION_TIME_TICK.equals(action)) {
                updateTime();
            }
        }
    };
}

From source file:com.example.maciej.mytask.MainActivity.java

@Override
protected void onResume() {
    super.onResume();
    mDateTimeTextView.setText(getCurrentTimeStamp());
    registerReceiver(mTickReceiver, new IntentFilter(Intent.ACTION_TIME_TICK));
}

From source file:org.samcrow.ridgesurvey.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setTitle(getString(R.string.map));//  ww w .  j  a v  a  2 s  . com

    // Check location permission
    final int permission = ActivityCompat.checkSelfPermission(this, LOCATION_PERMISSION);
    if (permission == PackageManager.PERMISSION_DENIED) {
        ActivityCompat.requestPermissions(this, new String[] { LOCATION_PERMISSION }, LOCATION_PERMISSION_CODE);
    }

    // Set up map graphics
    if (AndroidGraphicFactory.INSTANCE == null || new View(this).isInEditMode()) {
        AndroidGraphicFactory.createInstance(getApplication());
    }

    setContentView(R.layout.activity_main);

    mSelectionManager = new SelectionManager();

    mLocationFinder = new LocationFinder(this);

    // Set up upload status tracker
    mUploadStatusTracker = new UploadStatusTracker(this);
    mUploadStatusTracker.addListener((UploadStatusListener) findViewById(R.id.upload_status_bar));

    final LocalBroadcastManager manager = LocalBroadcastManager.getInstance(this);
    final IntentFilter filter = new IntentFilter();
    filter.addAction(UploadStatusTracker.ACTION_OBSERVATION_MADE);
    filter.addAction(UploadStatusTracker.ACTION_UPLOAD_STARTED);
    filter.addAction(UploadStatusTracker.ACTION_UPLOAD_SUCCESS);
    filter.addAction(UploadStatusTracker.ACTION_UPLOAD_FAILED);
    manager.registerReceiver(mUploadStatusTracker, filter);

    // Check for upload/delete every minute
    final IntentFilter tickFilter = new IntentFilter();
    tickFilter.addAction(Intent.ACTION_TIME_TICK);
    registerReceiver(new NetworkBroadcastReceiver(), tickFilter);

    // Set up compass
    mCompass = (Compass) findViewById(R.id.compass);
    mHeadingCalculator = new HeadingCalculator(this);
    if (mHeadingCalculator.isAvailable()) {
        Log.d(TAG, "Heading available");
        mHeadingCalculator.setHeadingListener(new HeadingListener() {
            @Override
            public void headingUpdated(double heading) {
                mCompass.setHeading(heading);
            }
        });
    } else {
        Log.d(TAG, "Heading not available");
        mCompass.setVisibility(View.INVISIBLE);
    }

    mPreferences = getSharedPreferences(TAG, MODE_PRIVATE);
    mPreferencesFacade = new AndroidPreferences(mPreferences);
    try {
        setUpMap();
    } catch (IOException e) {
        new AlertDialog.Builder(this).setTitle(R.string.failed_to_load_map).setMessage(e.getLocalizedMessage())
                .show();
        Log.e(TAG, "Failed to set up map", e);
    }

    startUpload();
}

From source file:com.aegiswallet.services.PeerBlockchainService.java

@Override
public void onCreate() {
    super.onCreate();

    nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

    application = (PayBitsApplication) getApplication();
    prefs = PreferenceManager.getDefaultSharedPreferences(this);
    final Wallet wallet = application.getWallet();

    blockChainFile = new File(getDir("blockstore", Context.MODE_PRIVATE), Constants.BLOCKCHAIN_FILENAME);

    final boolean blockChainFileExists = blockChainFile.exists();

    if (!blockChainFileExists) {
        wallet.clearTransactions(0);/*ww  w . ja  v  a  2  s  .co m*/
        wallet.setLastBlockSeenHeight(-1);
        wallet.setLastBlockSeenHash(null);
    }

    try {
        blockStore = new SPVBlockStore(Constants.NETWORK_PARAMETERS, blockChainFile);
        blockStore.getChainHead(); // detect corruptions as early as possible

        long earliestKeyCreationTime = wallet.getEarliestKeyCreationTime();

        if (earliestKeyCreationTime == 0)
            earliestKeyCreationTime = System.currentTimeMillis() - TimeUnit.DAYS.toMillis(7);

        if (!blockChainFileExists && earliestKeyCreationTime > 0) {
            Log.d(TAG, "creating blockchain from checkpoint. attmpting to at least...");
            try {
                final InputStream checkpointsInputStream = getAssets().open(Constants.CHECKPOINTS_FILENAME);
                CheckpointManager.checkpoint(Constants.NETWORK_PARAMETERS, checkpointsInputStream, blockStore,
                        earliestKeyCreationTime);
            } catch (final IOException x) {
                Log.e(TAG, "problem reading checkpoint file..." + x.getMessage());
            }
        }

    } catch (final BlockStoreException x) {
        blockChainFile.delete();

        final String msg = "blockstore cannot be created";
        throw new Error(msg, x);
    }

    try {
        blockChain = new BlockChain(Constants.NETWORK_PARAMETERS, wallet, blockStore);
    } catch (final BlockStoreException x) {
        throw new Error("blockchain cannot be created", x);
    }

    bestChainHeightEver = prefs.getInt(Constants.PREFS_KEY_BEST_CHAIN_HEIGHT_EVER, 0);

    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);
    registerReceiver(tickReceiver, new IntentFilter(Intent.ACTION_TIME_TICK));
    maybeRotateKeys();

    tagPrefs = application.getSharedPreferences(getString(R.string.tag_pref_filename), Context.MODE_PRIVATE);

}

From source file:tw.idv.gasolin.pycontw2012.ui.ScheduleFragment.java

@Override
public void onResume() {
    super.onResume();

    // Since we build our views manually instead of using an adapter, we
    // need to manually requery every time launched.
    requery();/*from  w  w  w. j  a v  a2  s  .co  m*/

    getActivity().getContentResolver().registerContentObserver(CoscupContract.Sessions.CONTENT_URI, true,
            mSessionChangesObserver);

    // Start listening for time updates to adjust "now" bar. TIME_TICK is
    // triggered once per minute, which is how we move the bar over time.
    final IntentFilter filter = new IntentFilter();
    filter.addAction(Intent.ACTION_TIME_TICK);
    filter.addAction(Intent.ACTION_TIME_CHANGED);
    filter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
    getActivity().registerReceiver(mReceiver, filter, null, new Handler());
}

From source file:com.google.android.apps.iosched.ui.ScheduleFragment.java

@Override
public void onResume() {
    super.onResume();

    // Since we build our views manually instead of using an adapter, we
    // need to manually requery every time launched.
    requery();/*www. ja v a2s.c  om*/

    getActivity().getContentResolver().registerContentObserver(ScheduleContract.Sessions.CONTENT_URI, true,
            mSessionChangesObserver);

    // Start listening for time updates to adjust "now" bar. TIME_TICK is
    // triggered once per minute, which is how we move the bar over time.
    final IntentFilter filter = new IntentFilter();
    filter.addAction(Intent.ACTION_TIME_TICK);
    filter.addAction(Intent.ACTION_TIME_CHANGED);
    filter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
    getActivity().registerReceiver(mReceiver, filter, null, new Handler());
}

From source file:com.slushpupie.deskclock.DeskClock.java

/** Called when the activity becomes visible. */
@Override//from   ww w  .j  ava 2 s  .c om
public void onStart() {
    super.onStart();

    IntentFilter filter = new IntentFilter();
    filter.addAction(Intent.ACTION_DOCK_EVENT);
    filter.addAction(Intent.ACTION_TIME_TICK);
    registerReceiver(intentReceiver, filter);

    isRunning = true;
    updateTime();
    handler.postDelayed(runMoveDisplay, prefsScreenSaverSpeed);
    if (prefsShowHints)
        Toast.makeText(getApplicationContext(), R.string.startup_toast, Toast.LENGTH_SHORT).show();
}

From source file:com.google.android.apps.iosched2.ui.ScheduleFragment.java

@Override
public void onResume() {
    super.onResume();

    SetupHelper.loadCurrentSetup(getActivity());

    // Since we build our views manually instead of using an adapter, we
    // need to manually requery every time launched.
    requery();/*from w  w  w  .j a v a2  s  .co m*/

    getActivity().getContentResolver().registerContentObserver(ScheduleContract.Sessions.CONTENT_URI, true,
            mSessionChangesObserver);

    // Start listening for time updates to adjust "now" bar. TIME_TICK is
    // triggered once per minute, which is how we move the bar over time.
    final IntentFilter filter = new IntentFilter();
    filter.addAction(Intent.ACTION_TIME_TICK);
    filter.addAction(Intent.ACTION_TIME_CHANGED);
    filter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
    getActivity().registerReceiver(mReceiver, filter, null, new Handler());
}

From source file:com.cleanwiz.applock.service.LockService.java

public void registerApplicationReceiver() {
    IntentFilter packageIntentFilter = new IntentFilter();
    IntentFilter eventIntentFilter = new IntentFilter();
    eventIntentFilter.addAction(Intent.ACTION_SCREEN_OFF);
    eventIntentFilter.addAction(Intent.ACTION_SCREEN_ON);
    eventIntentFilter.addAction(Intent.ACTION_TIME_TICK);
    eventIntentFilter.addAction(Intent.ACTION_USER_PRESENT);
    eventIntentFilter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION);
    packageIntentFilter.addAction(Intent.ACTION_PACKAGE_ADDED);
    packageIntentFilter.addAction(Intent.ACTION_PACKAGE_REMOVED);
    packageIntentFilter.addDataScheme("package");
    getApplicationContext().registerReceiver(packageReceiver, packageIntentFilter);
    getApplicationContext().registerReceiver(eventReceiver, eventIntentFilter);
    IntentFilter filter = new IntentFilter();
    filter.addAction(LOCK_SERVICE_LASTTIME);
    filter.addAction(LOCK_SERVICE_LEAVEAMENT);
    filter.addAction(LOCK_SERVICE_LEAVERTIME);
    filter.addAction(LOCK_SERVICE_LOCKSTATE);

    lastUnlockTimeSeconds = 0;//  w w w .  j a v  a2 s .c o  m
    allowedLeaveAment = application.getAllowedLeaveAment();
    leaverTime = application.getLeaverTime();
    lockState = application.getAppLockState();
    registerReceiver(new ServiceReceiver(), filter);
}

From source file:com.justwayward.reader.ui.activity.ReadActivity.java

@Override
public void initDatas() {
    recommendBooks = (Recommend.RecommendBooks) getIntent().getSerializableExtra(INTENT_BEAN);
    bookId = recommendBooks._id;//from   w  w w  .j  a  va 2 s.  c  o  m
    isFromSD = getIntent().getBooleanExtra(INTENT_SD, false);

    if (Intent.ACTION_VIEW.equals(getIntent().getAction())) {
        String filePath = Uri.decode(getIntent().getDataString().replace("file://", ""));
        String fileName;
        if (filePath.lastIndexOf(".") > filePath.lastIndexOf("/")) {
            fileName = filePath.substring(filePath.lastIndexOf("/") + 1, filePath.lastIndexOf("."));
        } else {
            fileName = filePath.substring(filePath.lastIndexOf("/") + 1);
        }

        CollectionsManager.getInstance().remove(fileName);
        // 
        File desc = FileUtils.createWifiTranfesFile(fileName);
        FileUtils.fileChannelCopy(new File(filePath), desc);
        // 
        recommendBooks = new Recommend.RecommendBooks();
        recommendBooks.isFromSD = true;
        recommendBooks._id = fileName;
        recommendBooks.title = fileName;

        isFromSD = true;
    }
    EventBus.getDefault().register(this);
    showDialog();

    mTvBookReadTocTitle.setText(recommendBooks.title);

    mTtsPlayer = TTSPlayerUtils.getTTSPlayer();
    ttsConfig = TTSPlayerUtils.getTtsConfig();

    intentFilter.addAction(Intent.ACTION_BATTERY_CHANGED);
    intentFilter.addAction(Intent.ACTION_TIME_TICK);

    CollectionsManager.getInstance().setRecentReadingTime(bookId);
    Observable.timer(1000, TimeUnit.MILLISECONDS).subscribe(new Action1<Long>() {
        @Override
        public void call(Long aLong) {
            //1
            EventManager.refreshCollectionList();
        }
    });
}