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.androidinspain.deskclock.alarms.AlarmActivity.java

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

    // Re-query for AlarmInstance in case the state has changed externally
    final long instanceId = AlarmInstance.getId(getIntent().getData());
    mAlarmInstance = AlarmInstance.getInstance(getContentResolver(), instanceId);

    if (mAlarmInstance == null) {
        LOGGER.i("No alarm instance for instanceId: %d", instanceId);
        finish();/*from   w  w  w  .  ja va2  s. c  o m*/
        return;
    }

    // Verify that the alarm is still firing before showing the activity
    if (mAlarmInstance.mAlarmState != AlarmInstance.FIRED_STATE) {
        LOGGER.i("Skip displaying alarm for instance: %s", mAlarmInstance);
        finish();
        return;
    }

    if (!mReceiverRegistered) {
        // Register to get the alarm done/snooze/dismiss intent.
        final IntentFilter filter = new IntentFilter(AlarmService.ALARM_DONE_ACTION);
        filter.addAction(AlarmService.ALARM_SNOOZE_ACTION);
        filter.addAction(AlarmService.ALARM_DISMISS_ACTION);
        registerReceiver(mReceiver, filter);
        mReceiverRegistered = true;
    }

    bindAlarmService();

    resetAnimations();
}

From source file:com.example.bluetooth_faster_connection.MainActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (D)/*w  w w  .  j  a  v a2 s. c  o  m*/
        Log.e(TAG, "+++ ON CREATE +++");

    // Set up the window layout
    requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
    setContentView(R.layout.main);
    getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title);

    // Set up the custom title
    mTitle = (TextView) findViewById(R.id.title_left_text);
    mTitle.setText(R.string.app_name);
    mTitle = (TextView) findViewById(R.id.title_right_text);
    mInfo = (TextView) findViewById(R.id.myText);

    Button mButton = (Button) findViewById(R.id.myButton);
    mButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            openOptionsMenu();
        }
    });

    // Get local Bluetooth adapter
    mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();

    // If the adapter is null, then Bluetooth is not supported
    if (mBluetoothAdapter == null) {
        Toast.makeText(this, "Bluetooth is not available", Toast.LENGTH_LONG).show();
        finish();
        return;
    }

    // register for background service broadcast.
    IntentFilter ifilt = new IntentFilter(DeviceDicoverService.DEVICE_CONNECTION_ADDRESS);
    ifilt.addAction(DeviceDicoverService.DEVICE_CONNECTION_INFO);
    registerReceiver(mReceiver, ifilt);

    // just for test purpose, should be deleted if not in test procedure.
    Intent service = new Intent(this, DeviceDicoverService.class);
    startService(service);

    wifii = (WifiManager) getSystemService(Context.WIFI_SERVICE);
    WifiInfo wInfo = wifii.getConnectionInfo();
}

From source file:com.htc.dotdesign.DrawingView.java

private void registerForToolBoxChange(Context context) {
    IntentFilter filter = new IntentFilter();
    filter.addAction(ToolBoxService.TOOL_BAR_ACTION_STATUS);
    if (context != null) {
        LocalBroadcastManager.getInstance(context).registerReceiver(mToolBarReceiver, filter);
    }//from  w w  w . j  a  v  a  2s. co m
}

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

@Override
public void onResume() {
    super.onResume();
    SetupHelper.loadCurrentSetup(getActivity());

    updateNotesTab();/*  w  ww  .j a v  a  2  s. c  o  m*/

    // 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_PACKAGE_ADDED);
    filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
    filter.addAction(Intent.ACTION_PACKAGE_REPLACED);
    filter.addDataScheme("package");
    getActivity().registerReceiver(mPackageChangesReceiver, filter);
}

From source file:cn.ucai.wechat.ui.MainActivity.java

private void registerBroadcastReceiver() {
    broadcastManager = LocalBroadcastManager.getInstance(this);
    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(Constant.ACTION_CONTACT_CHANAGED);
    intentFilter.addAction(Constant.ACTION_GROUP_CHANAGED);
    intentFilter.addAction(RPConstant.REFRESH_GROUP_RED_PACKET_ACTION);
    broadcastReceiver = new BroadcastReceiver() {

        @Override//ww  w .ja va2s  . c  om
        public void onReceive(Context context, Intent intent) {
            updateUnreadLabel();
            updateUnreadAddressLable();
            if (currentTabIndex == 0) {
                // refresh conversation list
                if (conversationListFragment != null) {
                    conversationListFragment.refresh();
                }
            } else if (currentTabIndex == 1) { // currentTabIndex=1?
                if (contactListFragment != null) {
                    contactListFragment.refresh();// ?
                }
            }
            String action = intent.getAction();
            if (action.equals(Constant.ACTION_GROUP_CHANAGED)) {
                if (EaseCommonUtils.getTopActivity(MainActivity.this).equals(GroupsActivity.class.getName())) {
                    GroupsActivity.instance.onResume();
                }
            }
            //red packet code : ???
            if (action.equals(RPConstant.REFRESH_GROUP_RED_PACKET_ACTION)) {
                if (conversationListFragment != null) {
                    conversationListFragment.refresh();
                }
            }
            //end of red packet code
        }
    };
    broadcastManager.registerReceiver(broadcastReceiver, intentFilter);
}

From source file:com.dudu.aios.ui.activity.MainRecordActivity.java

private void registerTFlashCardReceiver() {
    mTFlashCardReceiver = new TFlashCardReceiver();

    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(Intent.ACTION_MEDIA_MOUNTED);
    intentFilter.addAction(Intent.ACTION_MEDIA_REMOVED);
    intentFilter.addDataScheme("file");
    registerReceiver(mTFlashCardReceiver, intentFilter);
}

From source file:at.alladin.rmbt.android.test.RMBTLoopService.java

@Override
public void onCreate() {
    Log.d(TAG, "created");
    super.onCreate();

    partialWakeLock = ((PowerManager) getApplicationContext().getSystemService(Context.POWER_SERVICE))
            .newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "RMBTLoopWakeLock");
    partialWakeLock.acquire();//from   w  ww  .j  a v a2s  .com

    alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
    notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

    readConfig();

    geoLocation = new LocalGeoLocation(this);
    geoLocation.start();

    notificationBuilder = createNotificationBuilder();

    startForeground(NotificationIDs.LOOP_ACTIVE, notificationBuilder.build());
    final IntentFilter actionFilter = new IntentFilter(RMBTService.BROADCAST_TEST_FINISHED);
    actionFilter.addAction(RMBTService.BROADCAST_TEST_ABORTED);
    registerReceiver(receiver, actionFilter);

    final IntentFilter rmbtTaskActionFilter = new IntentFilter(RMBTTask.BROADCAST_TEST_START);
    registerReceiver(rmbtTaskReceiver, rmbtTaskActionFilter);

    final Intent alarmIntent = new Intent(ACTION_ALARM, null, this, getClass());
    alarm = PendingIntent.getService(this, 0, alarmIntent, 0);

    if (ConfigHelper.isLoopModeWakeLock(this)) {
        Log.d(TAG, "using dimWakeLock");
        dimWakeLock = ((PowerManager) getApplicationContext().getSystemService(Context.POWER_SERVICE))
                .newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP
                        | PowerManager.ON_AFTER_RELEASE, "RMBTLoopDimWakeLock");
        dimWakeLock.acquire();

        final Intent wakeupAlarmIntent = new Intent(ACTION_WAKEUP_ALARM, null, this, getClass());
        wakeupAlarm = PendingIntent.getService(this, 0, wakeupAlarmIntent, 0);

        final long now = SystemClock.elapsedRealtime();
        alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, now + 10000, 10000, wakeupAlarm);
    }

    bindService(new Intent(getApplicationContext(), RMBTService.class), this, BIND_AUTO_CREATE);
}

From source file:cn.wyl.superwechat.ui.MainActivity.java

private void registerBroadcastReceiver() {
    broadcastManager = LocalBroadcastManager.getInstance(this);
    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(Constant.ACTION_CONTACT_CHANAGED);
    intentFilter.addAction(Constant.ACTION_GROUP_CHANAGED);
    intentFilter.addAction(RedPacketConstant.REFRESH_GROUP_RED_PACKET_ACTION);
    broadcastReceiver = new BroadcastReceiver() {

        @Override/*from ww w .  java 2s . c  o  m*/
        public void onReceive(Context context, Intent intent) {
            updateUnreadLabel();
            updateUnreadAddressLable();
            // if (currentTabIndex == 0) {
            // refresh conversation list
            if (conversationListFragment != null) {
                conversationListFragment.refresh();
            }
            //} else if (currentTabIndex == 1) {
            if (contactListFragment != null) {
                contactListFragment.refresh();
            }
            // }
            String action = intent.getAction();
            if (action.equals(Constant.ACTION_GROUP_CHANAGED)) {
                if (EaseCommonUtils.getTopActivity(MainActivity.this).equals(GroupsActivity.class.getName())) {
                    GroupsActivity.instance.onResume();
                }
            }
            //red packet code : ???
            if (action.equals(RedPacketConstant.REFRESH_GROUP_RED_PACKET_ACTION)) {
                if (conversationListFragment != null) {
                    conversationListFragment.refresh();
                }
            }
            //end of red packet code
        }
    };
    broadcastManager.registerReceiver(broadcastReceiver, intentFilter);
}

From source file:com.google.android.apps.muzei.settings.ChooseSourceFragment.java

@Override
public void onResume() {
    super.onResume();
    updateSources();//from   w w  w  . j av a2 s . c  o m

    IntentFilter packageChangeIntentFilter = new IntentFilter();
    packageChangeIntentFilter.addAction(Intent.ACTION_PACKAGE_ADDED);
    packageChangeIntentFilter.addAction(Intent.ACTION_PACKAGE_CHANGED);
    packageChangeIntentFilter.addAction(Intent.ACTION_PACKAGE_REPLACED);
    packageChangeIntentFilter.addAction(Intent.ACTION_PACKAGE_REMOVED);
    packageChangeIntentFilter.addDataScheme("package");
    getContext().registerReceiver(mPackagesChangedReceiver, packageChangeIntentFilter);
}

From source file:com.lchtime.safetyexpress.ui.chat.hx.activity.HXMainActivity.java

private void registerBroadcastReceiver() {
    broadcastManager = LocalBroadcastManager.getInstance(this);
    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(Constant.ACTION_CONTACT_CHANAGED);
    intentFilter.addAction(Constant.ACTION_GROUP_CHANAGED);
    //      intentFilter.addAction(RPConstant.REFRESH_GROUP_RED_PACKET_ACTION);
    broadcastReceiver = new BroadcastReceiver() {

        @Override//from   www.j  ava2  s  .c  om
        public void onReceive(Context context, Intent intent) {
            updateUnreadLabel();
            updateUnreadAddressLable();
            if (currentTabIndex == 0) {
                // refresh conversation list
                if (conversationListFragment != null) {
                    conversationListFragment.refresh();
                }
            } else if (currentTabIndex == 1) {
                //                    if(contactListFragment != null) {
                //                        contactListFragment.refresh();
                //                    }
            }
            String action = intent.getAction();
            if (action.equals(Constant.ACTION_GROUP_CHANAGED)) {
                if (EaseCommonUtils.getTopActivity(HXMainActivity.this)
                        .equals(GroupsActivity.class.getName())) {
                    GroupsActivity.instance.onResume();
                }
            }
            //red packet code : ???
            /*      if (action.equals(RPConstant.REFRESH_GROUP_RED_PACKET_ACTION)){
                     if (conversationListFragment != null){
                        conversationListFragment.refresh();
                     }
                  }*/
            //end of red packet code
        }
    };
    broadcastManager.registerReceiver(broadcastReceiver, intentFilter);
}