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.github.howeyc.slideshow.activities.MainActivity.java

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

    debug("onResume");
    // refresh toolbar options (hide/show downloadNow)
    supportInvalidateOptionsMenu();//from   w w  w. j  ava 2  s  .  c o  m
    if (AppData.getFirstAppStart()) {
        AppData.setFirstAppStart(false);
        AppData.setTutorial(true);
    }

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    tutorial();
    // get localBroadcastManager instance to receive localBroadCasts
    if (broadcastManager == null) {
        broadcastManager = LocalBroadcastManager.getInstance(getApplicationContext());
    }
    // register broadcast receiver for UI update from service
    if (receiver == null) {
        IntentFilter filter = new IntentFilter();
        filter.addAction(Keys.ACTION_DOWNLOAD_FINISHED);
        filter.addAction(Keys.ACTION_PROGRESSUPDATE);
        filter.addCategory(Intent.CATEGORY_DEFAULT);
        receiver = new ResponseReceiver();
        broadcastManager.registerReceiver(receiver, filter);
    }

    if (GlobalPhoneFuncs.getFileList(AppData.getImagePath()).size() > 0) {
        if (!AppData.getImagePath().equals(mOldPath) || mOldRecursive != AppData.getRecursiveSearch()) {
            loadAdapter();
        }
    }

    updateFileList();

    // start on the page we left in onPause, unless it was the first or last picture (as this freezes the slideshow
    if (currentPage < pager.getAdapter().getCount() - 1 && currentPage > 0) {
        pager.setCurrentItem(currentPage);
    }

    setUpSlideShow();

    if (AppData.getSlideshow() && !paused) {
        startSlideshowCountDown();
    }
}

From source file:com.android.contacts.model.AccountTypeManager.java

/**
 * Internal constructor that only performs initial parsing.
 *///from w  w  w.ja va  2s . co  m
public AccountTypeManagerImpl(Context context) {
    mContext = context;
    mLocalAccountLocator = DeviceLocalAccountLocator.create(context);
    mTypeProvider = new AccountTypeProvider(context);
    mFallbackAccountType = new FallbackAccountType(context);

    mAccountManager = AccountManager.get(mContext);

    mExecutor = ContactsExecutors.getDefaultThreadPoolExecutor();
    mMainThreadExecutor = ContactsExecutors.newHandlerExecutor(mMainThreadHandler);

    // Request updates when packages or accounts change
    IntentFilter filter = new IntentFilter(Intent.ACTION_PACKAGE_ADDED);
    filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
    filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
    filter.addDataScheme("package");
    mContext.registerReceiver(mBroadcastReceiver, filter);
    IntentFilter sdFilter = new IntentFilter();
    sdFilter.addAction(Intent.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE);
    sdFilter.addAction(Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE);
    mContext.registerReceiver(mBroadcastReceiver, sdFilter);

    // Request updates when locale is changed so that the order of each field will
    // be able to be changed on the locale change.
    filter = new IntentFilter(Intent.ACTION_LOCALE_CHANGED);
    mContext.registerReceiver(mBroadcastReceiver, filter);

    mAccountManager.addOnAccountsUpdatedListener(this, mMainThreadHandler, false);

    ContentResolver.addStatusChangeListener(ContentResolver.SYNC_OBSERVER_TYPE_SETTINGS, this);

    if (Flags.getInstance().getBoolean(Experiments.CP2_DEVICE_ACCOUNT_DETECTION_ENABLED)) {
        // Observe changes to RAW_CONTACTS so that we will update the list of "Device" accounts
        // if a new device contact is added.
        mContext.getContentResolver().registerContentObserver(ContactsContract.RawContacts.CONTENT_URI,
                /* notifyDescendents */ true, new ContentObserver(mMainThreadHandler) {
                    @Override
                    public boolean deliverSelfNotifications() {
                        return true;
                    }

                    @Override
                    public void onChange(boolean selfChange) {
                        reloadLocalAccounts();
                    }

                    @Override
                    public void onChange(boolean selfChange, Uri uri) {
                        reloadLocalAccounts();
                    }
                });
    }
    loadAccountTypes();
}

From source file:cc.echonet.coolmicapp.MainActivity.java

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

    setContentView(R.layout.home);//  w w w  .  j  a v  a 2 s  .c om
    timerValue = (TextView) findViewById(R.id.timerValue);
    BroadcastReceiver mPowerKeyReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            String strAction = intent.getAction();
            if (strAction.equals(Intent.ACTION_SCREEN_OFF) || strAction.equals(Intent.ACTION_SCREEN_ON)
                    || strAction.equals(Intent.ACTION_USER_PRESENT)) {
                if (isThreadOn) {
                    RedFlashLight();
                }
            }
        }
    };
    final IntentFilter theFilter = new IntentFilter();
    /** System Defined Broadcast */
    theFilter.addAction(Intent.ACTION_SCREEN_ON);
    theFilter.addAction(Intent.ACTION_SCREEN_OFF);
    theFilter.addAction(Intent.ACTION_USER_PRESENT);

    getApplicationContext().registerReceiver(mPowerKeyReceiver, theFilter);

    imageView1 = (ImageView) findViewById(R.id.imageView1);

    Log.v("onCreate", (imageView1 == null ? "iv null" : "iv ok"));

    android.view.ViewGroup.LayoutParams layoutParams = imageView1.getLayoutParams();

    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
        layoutParams.height = 400;
    } else {
        layoutParams.height = 180;
    }

    imageView1.setLayoutParams(layoutParams);

    myClipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    animation.setDuration(500); // duration - half a second
    animation.setInterpolator(new LinearInterpolator()); // do not alter animation rate
    animation.setRepeatCount(Animation.INFINITE); // Repeat animation infinitely
    animation.setRepeatMode(Animation.REVERSE);
    start_button = (Button) findViewById(R.id.start_recording_button);
    stop_button = (Button) findViewById(R.id.stop_recording_button);
    buttonColor = start_button.getBackground();
    logArea = (TextView) findViewById(R.id.log_area);
    logArea.setMovementMethod(new ScrollingMovementMethod());

    coolmic = new CoolMic(this, "default");

    if (Wrapper.getState() == Wrapper.WrapperInitializationStatus.WRAPPER_UNINITIALIZED) {
        if (Wrapper.init() == Wrapper.WrapperInitializationStatus.WRAPPER_INITIALIZATION_ERROR) {
            Log.d("WrapperInit", Wrapper.getInitException().toString());
            Toast.makeText(getApplicationContext(),
                    "Could not initialize native components :( Blocking controls!", Toast.LENGTH_SHORT).show();
        } else {
            Toast.makeText(getApplicationContext(), "Native components initialized!", Toast.LENGTH_SHORT)
                    .show();
        }
    } else if (Wrapper.init() == Wrapper.WrapperInitializationStatus.WRAPPER_INITIALIZATION_ERROR) {
        Toast.makeText(getApplicationContext(),
                "Previous problem detected with native components :( Blocking controls!", Toast.LENGTH_SHORT)
                .show();
    } else if (Wrapper.init() != Wrapper.WrapperInitializationStatus.WRAPPER_INTITIALIZED) {
        Toast.makeText(getApplicationContext(), "Native components in unknown state!", Toast.LENGTH_SHORT)
                .show();
    }

    txtListeners = (TextView) findViewById(R.id.txtListeners);
    IntentFilter mStatusIntentFilter = new IntentFilter(Constants.BROADCAST_STREAM_STATS_SERVICE);
    LocalBroadcastManager.getInstance(this).registerReceiver(mStreamStatsReceiver, mStatusIntentFilter);
}

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

private void registerScreenReceiver() {
    mScreenReceiver = new ScreenReceiver();

    IntentFilter filter = new IntentFilter();
    // ???// w w  w.  j ava2s.  c  o  m
    filter.addAction(Intent.ACTION_SCREEN_OFF);
    // ??
    filter.addAction(Intent.ACTION_SCREEN_ON);
    // ??
    filter.addAction(Intent.ACTION_USER_PRESENT);
    // ??????
    // example?????????
    // ????pad??
    filter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);

    registerReceiver(mScreenReceiver, filter);
}

From source file:com.fanfou.app.opensource.HomePage.java

@Override
protected IntentFilter getIntentFilter() {
    final IntentFilter filter = new IntentFilter();
    filter.addAction(Constants.ACTION_STATUS_SENT);
    filter.addAction(Constants.ACTION_DRAFTS_SENT);
    filter.addAction(Constants.ACTION_NOTIFICATION);
    return filter;
}

From source file:hochschuledarmstadt.photostream_tools.PhotoStreamClientImpl.java

private void registerInternetAvailableBroadcastReceiver() {
    try {/* ww  w . j av a2s  .  c om*/
        IntentFilter intentFilter = new IntentFilter();
        intentFilter.addAction(INTENT_CONNECTIVITY_CHANGE);
        context.registerReceiver(internetAvailableBroadcastReceiver, intentFilter);
    } catch (Exception e) {
    }
}

From source file:com.oo58.game.texaspoker.AppActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //         this.getWindow().setFlags(FLAG_HOMEKEY_DISPATCHED, FLAG_HOMEKEY_DISPATCHED);//
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    mContext = AppActivity.this;

    try {/*from   w ww  .  j a v  a  2s.c  o  m*/
        ApplicationInfo appInfo = this.getPackageManager().getApplicationInfo(getPackageName(),
                PackageManager.GET_META_DATA);
        String msg = appInfo.metaData.getString("data_Name");

        //         int channelid = Integer.parseInt(msg) ;
        //         
        //         System.out.println(channelid);

    } catch (NameNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    mAct = this;
    allContext = this.getApplicationContext();
    mTencent = Tencent.createInstance("1104823392", getApplicationContext());
    PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
    mWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "MyLock");
    mWakeLock.acquire();

    MobclickAgent.setDebugMode(false);
    MobclickAgent.updateOnlineConfig(this);
    AnalyticsConfig.enableEncrypt(true);

    checkUpdate();

    PackageManager pm2 = getPackageManager();
    homeInfo = pm2.resolveActivity(new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME), 0);

    mNetChecker.initAndRegListener(mContext);

    mWXPay.init(this);

    MobClickCppHelper.init(this);

    //      // logcatdebug
    //       XGPushConfig.enableDebug(this, true);
    //      // registerPush(getApplicationContext(), XGIOperateCallback)callback
    //      // registerPush(getApplicationContext(),account)
    //      // 
    //      // ApplicationContext
    //      Context context = getApplicationContext();
    //      XGPushManager.registerPush(context);    
    //       
    //      // 2.362
    //      Intent service = new Intent(context, XGPushService.class);
    //      context.startService(service);

    // API
    // registerPush(context,account)registerPush(context,account, XGIOperateCallback)accountAPPqqopenid
    // registerPush(context,"*")account="*"
    // unregisterPush(context)
    // setTag(context, tagName)
    // deleteTag(context, tagName)

    updateListViewReceiver = new MsgReceiver();
    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction("com.oo58.game.texaspoker.activity.UPDATE_LISTVIEW");
    registerReceiver(updateListViewReceiver, intentFilter);

    XGPushManager.registerPush(getApplicationContext(), new XGIOperateCallback() {
        @Override
        public void onSuccess(Object data, int flag) {
            //                  Log.w(Constants.LogTag,
            //                        "+++ register push sucess. token:" + data);

        }

        @Override
        public void onFail(Object data, int errCode, String msg) {
            //                  Log.w(Constants.LogTag,
            //                        "+++ register push fail. token:" + data
            //                              + ", errCode:" + errCode + ",msg:"
            //                              + msg);

        }
    });

    //javajosnC++demo
    /*      JSONObject jsonObj = new JSONObject();  
            try {
             jsonObj.put("Int_att",25);
               jsonObj.put("String_att","str");//string  
               jsonObj.put("Double_att",12.25);//double  
               jsonObj.put("Boolean_att",true);//boolean  
          } catch (JSONException e) {
             // TODO Auto-generated catch block
             e.printStackTrace();
          }//int  
            
            PushJson(jsonObj.toString()) ;*/

}

From source file:com.concentricsky.android.khanacademy.app.ManageDownloadsActivity.java

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

    gridView = (GridView) findViewById(R.id.grid);
    gridView.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE_MODAL);
    gridView.setMultiChoiceModeListener(multiChoiceModeListener);
    gridView.setOnItemClickListener(itemClickListener);

    View emptyView = getLayoutInflater().inflate(R.layout.listview_empty, null, false);
    ((TextView) emptyView.findViewById(R.id.text_list_empty)).setText(R.string.msg_no_downloaded_videos);
    ViewGroup.LayoutParams p = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT);
    addContentView(emptyView, p);/*  w  w  w .j av a  2s.c  om*/

    gridView.setEmptyView(emptyView);

    requestDataService(new ObjectCallback<KADataService>() {
        @Override
        public void call(final KADataService dataService) {
            ManageDownloadsActivity.this.dataService = dataService;

            CursorAdapter adapter = new Adapter(ManageDownloadsActivity.this, null, 0,
                    dataService.getThumbnailManager());
            gridView.setAdapter(adapter);

            new AsyncTask<Void, Void, Cursor>() {
                @Override
                protected Cursor doInBackground(Void... arg) {
                    return getCursor();
                }

                @Override
                protected void onPostExecute(Cursor cursor) {
                    ((CursorAdapter) gridView.getAdapter()).changeCursor(cursor);
                }
            }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);

            final ActionBar ab = getActionBar();
            ab.setDisplayHomeAsUpEnabled(true);

            ab.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
            ab.setTitle("");

            setupListNavigation();

            // The receiver performs actions that require a dataService, so register it here.
            IntentFilter filter = new IntentFilter();
            filter.addAction(ACTION_LIBRARY_UPDATE);
            filter.addAction(ACTION_BADGE_EARNED);
            filter.addAction(ACTION_OFFLINE_VIDEO_SET_CHANGED);
            filter.addAction(ACTION_DOWNLOAD_PROGRESS_UPDATE);
            filter.addAction(ACTION_TOAST);
            broadcastManager.registerReceiver(receiver, filter);
        }
    });
}

From source file:com.grupohqh.carservices.operator.ManipulateCarActivity.java

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

    if (getIntent().getExtras().containsKey("userId"))
        userId = getIntent().getExtras().getInt("userId");
    if (getIntent().getExtras().containsKey("carOwnerId"))
        carOwnerId = getIntent().getExtras().getInt("carOwnerId");

    CARBRAND_URL = getString(R.string.base_url) + getString(R.string.carbrands_url);
    CARLINE_URL = getString(R.string.base_url) + getString(R.string.carmodels_url);
    SAVECAR_URL = getString(R.string.base_url) + "savecar/";
    SAVEPHOTO_URL = getString(R.string.base_url) + "savephoto/";
    hasCamera = this.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_ANY);

    etTagNumber = (EditText) findViewById(R.id.etTagNumber);
    etUsernameOwner = (EditText) findViewById(R.id.etUsernameOwner);
    etCarBrand = (EditText) findViewById(R.id.etCarBrand);
    etCarModel = (EditText) findViewById(R.id.etCarModel);
    etCarYear = (EditText) findViewById(R.id.etCarYear);
    etColor = (EditText) findViewById(R.id.etCarColor);
    etSerialNumber = (EditText) findViewById(R.id.etSerialNumber);
    etLicensePlate = (EditText) findViewById(R.id.etLicensePlate);
    etKM = (EditText) findViewById(R.id.etKm);
    imgCar = (ImageView) findViewById(R.id.imgCar);
    spCarBrand = (Spinner) findViewById(R.id.spCarBrand);
    spCarModel = (Spinner) findViewById(R.id.spCarModel);
    btnSaveCar = (Button) findViewById(R.id.btnSaveCar);
    btnTakePicture = (Button) findViewById(R.id.btnTakePicture);
    bar = (ProgressBar) findViewById(R.id.progressBar);
    viewUsername = findViewById(R.id.viewUsername);

    if (savedInstanceState != null) {
        bm = savedInstanceState.getParcelable("bm");
        if (bm != null)
            imgCar.setImageBitmap(bm);//w  w  w . j a  va 2 s .c om
    }

    bar.setVisibility(View.GONE);
    etCarBrand.setVisibility(View.GONE);
    etCarModel.setVisibility(View.GONE);
    viewUsername.setVisibility(carOwnerId == 0 ? View.VISIBLE : View.GONE);

    btnTakePicture.setEnabled(hasCamera);
    btnTakePicture.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            final Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
            intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(getTempFile(ManipulateCarActivity.this)));
            startActivityForResult(intent, CAPTURE_IMAGE);
        }
    });

    btnSaveCar.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (validate())
                new SaveCarAsyncTask().execute(SAVECAR_URL);
        }
    });

    spCarBrand.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            if (position == 0)
                ((TextView) parent.getChildAt(position)).setTextColor(Color.GRAY);
            if (mapBrands.get(brands.get(position)) == otherId) {
                etCarBrand.setVisibility(View.VISIBLE);
                etCarModel.setVisibility(View.VISIBLE);
                spCarModel.setVisibility(View.GONE);
                etCarBrand.requestFocus();
            } else {
                etCarBrand.setVisibility(View.GONE);
                etCarModel.setVisibility(View.GONE);
                spCarModel.setVisibility(View.VISIBLE);
                new LoadCarModelsAsyncTask().execute(CARLINE_URL + mapBrands.get(brands.get(position)) + "/");
                reload = true;
            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {

        }
    });

    spCarModel.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            if (position == 0)
                ((TextView) parent.getChildAt(position)).setTextColor(Color.GRAY);
            if (mapModels.get(models.get(position)) == otherId) {
                etCarModel.setVisibility(View.VISIBLE);
                etCarModel.requestFocus();
            } else {
                etCarModel.setVisibility(View.GONE);
            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {

        }
    });

    if (useMiniMe) {
        manager = (UsbManager) getSystemService(Context.USB_SERVICE);
        usbCommunication = UsbCommunication.newInstance();

        IntentFilter filter = new IntentFilter();
        filter.addAction(UsbManager.ACTION_USB_DEVICE_ATTACHED); // will intercept by system
        filter.addAction(UsbManager.ACTION_USB_DEVICE_DETACHED);
        filter.addAction(ACTION_USB_PERMISSION);
        registerReceiver(usbReceiver, filter);

        etEPC = (EditText) findViewById(R.id.etEPC);
        btnReadTAG = (Button) findViewById(R.id.btnReadTAG);
        txtStatus = (TextView) findViewById(R.id.txtStatus);
        btnReadTAG.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                etEPC.setText("");
                if (txtStatus.getText().toString().equals("conectado")) {
                    readTag();
                } else {
                    Toast.makeText(getBaseContext(), "dispositivo " + txtStatus.getText(), Toast.LENGTH_LONG)
                            .show();
                }
            }
        });
    }

    etKM.addTextChangedListener(new NumberTextWatcher(etKM));
}

From source file:com.jjoe64.graphview_demos.fragments.Home.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    rootView = inflater.inflate(R.layout.fragment_home, container, false);

    if (SHOW_DEBUG) {
        Log.d(TAG, "New FTDriver");
    }/*from  www.j a  v a2s  .  c om*/

    // get service
    mSerial = new Physicaloid(getActivity());

    if (SHOW_DEBUG) {
        Log.d(TAG, "New instance : " + mSerial);
    }
    // listen for new devices
    IntentFilter filter = new IntentFilter();
    filter.addAction(UsbManager.ACTION_USB_DEVICE_ATTACHED);
    filter.addAction(UsbManager.ACTION_USB_DEVICE_DETACHED);
    getActivity().registerReceiver(mUsbReceiver, filter);

    if (SHOW_DEBUG) {
        Log.d(TAG, "FTDriver beginning");
    }
    closeUsbSerial();
    openUsbSerial();

    return rootView;
}