Example usage for android.content IntentFilter addAction

List of usage examples for android.content IntentFilter addAction

Introduction

In this page you can find the example usage for android.content IntentFilter addAction.

Prototype

public final void addAction(String action) 

Source Link

Document

Add a new Intent action to match against.

Usage

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;//from   w ww  . j a  v  a 2s.  c o m
    allowedLeaveAment = application.getAllowedLeaveAment();
    leaverTime = application.getLeaverTime();
    lockState = application.getAppLockState();
    registerReceiver(new ServiceReceiver(), filter);
}

From source file:com.bullmobi.message.services.BathService.java

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

    mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    mLanguage = getResources().getConfiguration().locale.getLanguage();

    // Listen for the config changes to update notification just
    // once locale has changed.
    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(Intent.ACTION_CONFIGURATION_CHANGED);
    registerReceiver(mReceiver, intentFilter);

    synchronized (monitor) {
        sCreated = true;/*  w w w  .j a  v  a 2s  . c  o m*/
        //stop system Keyguard
        //          KeyguardManager km = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
        //          KeyguardManager.KeyguardLock mKeyguardLock = km.newKeyguardLock("");
        //          mKeyguardLock.disableKeyguard();
        // Register for add / remove service events.
        intentFilter = new IntentFilter();
        intentFilter.addAction(ACTION_ADD_SERVICE);
        intentFilter.addAction(ACTION_REMOVE_SERVICE);
        mLocalBroadcastManager = LocalBroadcastManager.getInstance(this);
        mLocalBroadcastManager.registerReceiver(mReceiver, intentFilter);

        if (sServiceMap.isEmpty()) {
            stopSelf();
        } else {
            // Init all children
            Set<Map.Entry<Class, ChildService>> set = sServiceMap.entrySet();
            for (Map.Entry<Class, ChildService> entry : set) {
                ChildService child = entry.getValue();
                child.setContext(this);
                child.onCreate();

                mMap.put(entry.getKey(), child);
            }
            sServiceMap.clear();

            startForeground(App.ID_NOTIFY_BATH, buildNotification());
        }
    }
}

From source file:com.javadog.cgeowear.cgeoWear.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_cgeo_wear);

    Intent i = getIntent();//from ww  w. j a  va2s  .c om

    //Let users know not to launch the app directly if they did (it's not necessary)
    if (!ListenerService.PATH_INIT.equals(i.getAction())) {
        new AlertDialog.Builder(this).setMessage(getString(R.string.app_direct_launch_warning))
                .setOnDismissListener(new DialogInterface.OnDismissListener() {
                    @Override
                    public void onDismiss(DialogInterface dialog) {
                        cgeoWear.this.finish();
                    }
                }).setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        cgeoWear.this.finish();
                    }
                }).show();
    }

    tv_cacheName = (TextView) findViewById(R.id.textview_cache_name);
    tv_geocode = (TextView) findViewById(R.id.textview_geocode);
    tv_distance = (TextView) findViewById(R.id.textview_distance);
    iv_compass = (ImageView) findViewById(R.id.compass);

    initScreen(i);

    //Register BroadcastReceiver for location updates
    broadcastManager = LocalBroadcastManager.getInstance(getApplicationContext());
    IntentFilter updateFilter = new IntentFilter();
    updateFilter.addAction(ListenerService.PATH_UPDATE_DISTANCE);
    updateFilter.addAction(ListenerService.PATH_UPDATE_DIRECTION);
    updateFilter.addAction(ListenerService.PATH_UPDATE_LOCATION);
    updateFilter.addAction(ListenerService.PATH_KILL_APP);
    broadcastManager.registerReceiver(broadcastReceiver, updateFilter);

    apiClient = new GoogleApiClient.Builder(this, this, this).addApi(Wearable.API).build();
    apiClient.connect();
}

From source file:com.bluros.music.activities.BaseActivity.java

@Override
protected void onStart() {
    super.onStart();

    final IntentFilter filter = new IntentFilter();
    // Play and pause changes
    filter.addAction(MusicService.PLAYSTATE_CHANGED);
    // Track changes
    filter.addAction(MusicService.META_CHANGED);
    // Update a list, probably the playlist fragment's
    filter.addAction(MusicService.REFRESH);
    // If a playlist has changed, notify us
    filter.addAction(MusicService.PLAYLIST_CHANGED);
    // If there is an error playing a track
    filter.addAction(MusicService.TRACK_ERROR);

    registerReceiver(mPlaybackStatus, filter);
}

From source file:com.dwdesign.tweetings.fragment.MentionsFragment.java

@Override
public void onResume() {
    super.onResume();
    IntentFilter filter = new IntentFilter();
    filter.addAction(TweetingsApplication.BROADCAST_SYNC_ACTION);
    filter.addAction(BROADCAST_VOLUME_UP);
    filter.addAction(BROADCAST_VOLUME_DOWN);
    registerReceiver(receiver, filter);//from   w  w  w.  j av a 2 s .  co m

    if (mPreferences.getBoolean(PREFERENCE_KEY_SYNC_ENABLED, false)) {
        getSync();
    }
}

From source file:com.dwdesign.tweetings.fragment.HomeTimelineFragment.java

@Override
public void onResume() {
    super.onResume();
    IntentFilter filter = new IntentFilter();
    filter.addAction(TweetingsApplication.BROADCAST_SYNC_ACTION);
    filter.addAction(BROADCAST_VOLUME_UP);
    filter.addAction(BROADCAST_VOLUME_DOWN);

    registerReceiver(receiver, filter);/*from w ww .  j av  a2s.c om*/
    if (mPreferences.getBoolean(PREFERENCE_KEY_SYNC_ENABLED, false)) {
        getSync();
    }
}

From source file:com.andrewquitmeyer.MarkYourTerritory.DemoKitActivity.java

/** Called when the activity is first created. */
@Override/*w  w w .  j  av a  2  s.  co m*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mUsbManager = UsbManager.getInstance(this);
    mPermissionIntent = PendingIntent.getBroadcast(this, 0, new Intent(ACTION_USB_PERMISSION), 0);
    IntentFilter filter = new IntentFilter(ACTION_USB_PERMISSION);
    filter.addAction(UsbManager.ACTION_USB_ACCESSORY_DETACHED);
    registerReceiver(mUsbReceiver, filter);

    if (getLastNonConfigurationInstance() != null) {
        mAccessory = (UsbAccessory) getLastNonConfigurationInstance();
        openAccessory(mAccessory);
    }

    setContentView(R.layout.maintwo);
    nodeviceview = (View) findViewById(R.id.noDevice);

    enableControls(false);
}

From source file:com.classiqo.nativeandroid_32bitz.MediaNotificationManager.java

public void startNotification() {
    if (!mStarted) {
        mMetadata = mController.getMetadata();
        mPlaybackState = mController.getPlaybackState();

        Notification notification = createNotification();

        if (notification != null) {
            mController.registerCallback(mCb);
            IntentFilter filter = new IntentFilter();
            filter.addAction(ACTION_NEXT);
            filter.addAction(ACTION_PAUSE);
            filter.addAction(ACTION_PLAY);
            filter.addAction(ACTION_PREV);
            filter.addAction(ACTION_STOP_CASTING);
            mService.registerReceiver(this, filter);

            mService.startForeground(NOTIFICATION_ID, notification);
            mStarted = true;// ww  w  . j av a 2  s. c o m
        }
    }
}

From source file:com.example.parking.ParkingInformationActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mDBAdapter = new DBAdapter(this);
    setContentView(R.layout.activity_parking_information);
    mParkNameTV = (TextView) findViewById(R.id.tv_parking_name);
    mParkNameTV.setText(R.string.park_name_fixed);
    mParkNumberTV = (TextView) findViewById(R.id.tv_parking_number);
    mParkNumberTV.setText("?:" + this.getString(R.string.park_number_fixed));
    mCarType = (Spinner) findViewById(R.id.sp_car_type);
    mParkingType = (Spinner) findViewById(R.id.sp_parking_type);
    mLocationNumber = (Spinner) findViewById(R.id.sp_parking_location);
    mLicensePlateNumberTV = (TextView) findViewById(R.id.tv_license_plate_number);
    Intent intent = getIntent();/*w  w  w.  j  a v a  2 s .c  o m*/
    Bundle bundle = intent.getExtras();
    mLicensePlateNumberTV.setText(bundle.getString("licensePlate"));
    mStartTime = (TextView) findViewById(R.id.tv_start_time_arriving);
    new TimeThread().start();
    mOkButton = (Button) findViewById(R.id.bt_confirm_arriving);
    mOkButton.setOnClickListener(new InsertOnclickListener(mLicensePlateNumberTV.getText().toString(),
            mCarType.getSelectedItem().toString(), mParkingType.getSelectedItem().toString(),
            Integer.parseInt(mLocationNumber.getSelectedItem().toString()),
            DateFormat.format("yyyy-MM-dd HH:mm:ss", System.currentTimeMillis()).toString(), null, null,
            ""));
    mPhotoBT = (Button) findViewById(R.id.bt_camera_arriving);
    mPhotoBT.setOnClickListener(new Button.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mEnterImage != null) {
                Toast.makeText(getApplicationContext(), "?", Toast.LENGTH_SHORT)
                        .show();
            } else {
                openTakePhoto();
            }
        }
    });
    mPhotoTitleTV = (TextView) findViewById(R.id.tv_photo_title_arriving);
    mEnterImageIV = (ImageView) findViewById(R.id.iv_photo_arriving);
    mEnterImageIV.setOnClickListener(new Button.OnClickListener() {
        @Override
        public void onClick(View v) {
            LayoutInflater inflater = LayoutInflater.from(getApplicationContext());
            View imgEntryView = inflater.inflate(R.layout.dialog_photo_entry, null); // 
            final AlertDialog dialog = new AlertDialog.Builder(ParkingInformationActivity.this).create();
            ImageView img = (ImageView) imgEntryView.findViewById(R.id.iv_large_image);
            Button deleteBT = (Button) imgEntryView.findViewById(R.id.bt_delete_image);
            img.setImageBitmap(mEnterImage);
            dialog.setView(imgEntryView); // dialog
            dialog.show();
            imgEntryView.setOnClickListener(new OnClickListener() {
                public void onClick(View paramView) {
                    dialog.cancel();
                }
            });
            deleteBT.setOnClickListener(new OnClickListener() {
                public void onClick(View paramView) {
                    mEnterImage = null;
                    mEnterImageIV.setImageResource(drawable.ic_photo_background_64px);
                    dialog.cancel();
                }
            });
        }
    });
    getActionBar().setDisplayHomeAsUpEnabled(true);
    IntentFilter filter = new IntentFilter();
    filter.addAction("ExitApp");
    registerReceiver(mReceiver, filter);
}

From source file:com.acrr.acdisplay.services.BathService.java

@Override
public void onCreate() {
    super.onCreate();
    mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    mLanguage = getResources().getConfiguration().locale.getLanguage();

    // Listen for the config changes to update notification just
    // once locale has changed.
    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(Intent.ACTION_CONFIGURATION_CHANGED);
    registerReceiver(mReceiver, intentFilter);

    synchronized (monitor) {
        sCreated = true;/*from  w w  w .ja  va 2 s.c  om*/
        sRunning = true;

        // Register for add / remove service events.
        intentFilter = new IntentFilter();
        intentFilter.addAction(ACTION_ADD_SERVICE);
        intentFilter.addAction(ACTION_REMOVE_SERVICE);
        mLocalBroadcastManager = LocalBroadcastManager.getInstance(this);
        mLocalBroadcastManager.registerReceiver(mReceiver, intentFilter);

        if (sServiceMap.isEmpty()) {
            stopMySelf();
        } else {
            // Init all children
            Set<Map.Entry<Class, ChildService>> set = sServiceMap.entrySet();
            for (Map.Entry<Class, ChildService> entry : set) {
                ChildService child = entry.getValue();
                child.setContext(this);
                child.onCreate();

                mMap.put(entry.getKey(), child);
            }
            sServiceMap.clear();

            startForeground(App.ID_NOTIFY_BATH, buildNotification());
        }
    }
}