Example usage for android.content IntentFilter IntentFilter

List of usage examples for android.content IntentFilter IntentFilter

Introduction

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

Prototype

public IntentFilter() 

Source Link

Document

New empty IntentFilter.

Usage

From source file:at.vcity.androidimsocket.services.IMService.java

@Override
public void onCreate() {
    mNM = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

    localstoragehandler = new LocalStorageHandler(this);
    // Display a notification about us starting.  We put an icon in the status bar.
    conManager = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);
    //new LocalStorageHandler(this);
    IntentFilter i = new IntentFilter();
    i.addAction("AlarmReceiver");
    registerReceiver(alarmReceiver, i);/*from w  ww  . j a  v  a2 s  .co  m*/
}

From source file:au.com.micropacific.cordova.CipherlabRS30Plugin.java

public void initialise(CallbackContext callbackContext) {
    Log.v("CipherlabRS30Plugin", "CipherlabRS30Plugin.initialise()");
    try {/*w  w w.j  a v  a2s  .  c  o m*/
        Log.v("CipherlabRS30Plugin", "com.cipherlab.barcode.GeneralString.Intent_SOFTTRIGGER_DATA: "
                + com.cipherlab.barcode.GeneralString.Intent_SOFTTRIGGER_DATA);
        if (cordova.getActivity() == null) {
            Log.v("CipherlabRS30Plugin", "cordova.getActivity() is null");
        } else {
            Log.v("CipherlabRS30Plugin", "cordova.getActivity() is something");
        }

        filter = new IntentFilter();
        filter.addAction(com.cipherlab.barcode.GeneralString.Intent_SOFTTRIGGER_DATA);
        filter.addAction(com.cipherlab.barcode.GeneralString.Intent_PASS_TO_APP);
        filter.addAction(com.cipherlab.barcode.GeneralString.Intent_READERSERVICE_CONNECTED);

        mReaderManager = ReaderManager.InitInstance(cordova.getActivity());
        mDataReceiver = new DataReceiver(this, this.mReaderManager);
        cordova.getActivity().registerReceiver(mDataReceiver, filter);

        Log.v("CipherlabRS30Plugin", "Got reader");
    } catch (Exception e) {
        StringWriter writer = new StringWriter();
        PrintWriter printWriter = new PrintWriter(writer);
        e.printStackTrace(printWriter);
        printWriter.flush();

        String stackTrace = writer.toString();

        Log.v("CipherlabRS30Plugin", "Error starting reader manager: " + stackTrace);
    }

    Log.v("CipherlabRS30Plugin", "CipherlabRS30Plugin.initialise() Done");

    callbackContext.success();
}

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 .  ja  v a2s. c om
    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.lge.helloFriendsCamera.MainActivity.java

private IntentFilter getFilter() {
    IntentFilter mFilter = new IntentFilter();
    mFilter.addAction(WifiClient.ACTION_WIFI_STATE);
    return mFilter;
}

From source file:com.liferay.alerts.activity.CommentsActivity.java

private void _registerBroadcastReceiver() {
    IntentFilter filter = new IntentFilter();
    filter.addAction(ACTION_ADD_COMMENT);
    filter.addAction(ACTION_UPDATE_COMMENTS_LIST);

    _receiver = new BroadcastReceiver() {

        @Override/*from w  w w.j a v a  2s .com*/
        public void onReceive(Context context, Intent intent) {
            String action = intent.getAction();
            ListView listView = (ListView) findViewById(R.id.comments);

            if (ACTION_UPDATE_COMMENTS_LIST.equals(action)) {
                ArrayList<Alert> alerts = intent.getParcelableArrayListExtra(EXTRA_ALERTS);

                ArrayAdapter<Alert> adapter = new CommentListAdapter(getApplicationContext(), alerts);

                listView.setAdapter(adapter);
            } else if (ACTION_ADD_COMMENT.equals(action)) {
                Alert alert = intent.getParcelableExtra(EXTRA_ALERT);

                ArrayAdapter<Alert> adapter = (ArrayAdapter<Alert>) listView.getAdapter();

                adapter.add(alert);
            }
        }

    };

    _getBroadcastManager().registerReceiver(_receiver, filter);
}

From source file:com.sina.weibo.sdk.demo.openapi.user_homeActivity.java

/**
 * @see {@link Activity#onCreate}//from   ww w .ja v a 2 s  . c om
 */

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.weibo_item);
    //mLogoutButton = (Button) findViewById(R.id.logout);

    // ??? Token
    mAccessToken = AccessTokenKeeper.readAccessToken(this);
    // ???
    mUsersAPI = new UsersAPI(this, Constants.APP_KEY, mAccessToken);
    mStatusesAPI = new StatusesAPI(this, Constants.APP_KEY, mAccessToken);
    getUserInfo();

    //
    this.findViewById(R.id.home_page).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            startActivity(new Intent(user_homeActivity.this, mytestActivity.class));
        }
    });
    this.findViewById(R.id.send_page).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            startActivity(new Intent(user_homeActivity.this, WBStatus_sendAPIActivity.class));
        }
    });
    //
    //
    this.findViewById(R.id.fllowers).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            startActivity(new Intent(user_homeActivity.this, user_fllowers.class));
        }
    });
    //?
    this.findViewById(R.id.friends).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            startActivity(new Intent(user_homeActivity.this, user_friends.class));
        }
    });
    //
    mWeiboShareAPI = WeiboShareSDK.createWeiboAPI(this, Constants.APP_KEY);
    mWeiboShareAPI.registerApp();
    shearMessageReceiver = new ShearMessageReceiver();
    IntentFilter filter = new IntentFilter();
    filter.addAction(ACTION_SHEAR_RESULT);
    registerReceiver(shearMessageReceiver, filter);
    this.findViewById(R.id.share).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (!mWeiboShareAPI.isWeiboAppInstalled()) {
                Toast.makeText(user_homeActivity.this, "", Toast.LENGTH_LONG).show();
            }
            //
            if (true) {
                Bundle bundle = new Bundle();
                Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_logo);
                bundle.putString(WBConstants.SDK_WEOYOU_SHARETITLE, "share our app to others");
                bundle.putString(WBConstants.SDK_WEOYOU_SHAREDESC, "say something...");
                bundle.putString(WBConstants.SDK_WEOYOU_SHAREURL, "http://github/laterlater.com");
                bundle.putString("shareBackScheme", "weiboDemo://share");
                bundle.putString(SHARE_APP_NAME, "app name");
                bundle.putString(PARAM_SHARE_FROM, EXTEND_SHARE_570);
                bundle.putByteArray(WBConstants.SDK_WEOYOU_SHAREIMAGE, bitMapToBytes(bitmap));
                mWeiboShareAPI.shareMessageToWeiyou(user_homeActivity.this, bundle);
            } else {
                Toast.makeText(user_homeActivity.this, "?", Toast.LENGTH_LONG).show();
            }
        }
    });
    this.findViewById(R.id.logout).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mAccessToken != null && mAccessToken.isSessionValid()) {
                new LogoutAPI(user_homeActivity.this, Constants.APP_KEY, mAccessToken)
                        .logout(mLogoutRequestListener);
            }
        }
    });
}

From source file:com.jacr.instagramtrendreader.Main.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    setContentView(R.layout.activity_main);

    /* Customizing ActionBar */
    Resources r = getResources();
    ActionBar ab = super.getActionBar(false);
    ab.setIcon(r.getDrawable(R.drawable.ic_menu_home));
    ab.setTitle(Util.getTitleActivity(getString(R.string.title_my_gallery_app)));

    /* Views *//*w w  w.  j a  v  a  2s . c  o m*/
    layoutThumbnail = (TableLayout) findViewById(R.id.layoutThumbnail);
    layoutThumbnail.setPadding(1, 1, 1, 1);

    /* Setting Viewpager and Indicator */
    mPager = (ViewPager) findViewById(R.id.pagerMain);
    mAdapter = new ViewPagerAdapter<MainFragment>(getSupportFragmentManager());
    mPager.setOnPageChangeListener(new OnPageChangeListener() {

        @Override
        public void onPageScrollStateChanged(int arg0) {
        }

        @Override
        public void onPageScrolled(int arg0, float arg1, int arg2) {
        }

        @Override
        public void onPageSelected(int arg0) {
            int key = feedReader.getListThumbnailKeys().get(arg0);
            feedReader.highlightThumbnail(key);

        }

    });

    /* Receiver */
    mReceiver = new BroadcastReceiver() {

        @Override
        public void onReceive(Context context, Intent intent) {
            String action = intent.getAction();
            Bundle extras = intent.getExtras();
            if (action.contentEquals(ACTION_IMAGE_CLICK)) {
                int key = extras.getInt(ACTION_IMAGE_CLICK);
                if (key != -1) {
                    Intent in = new Intent(Main.this, ImageDetails.class);
                    Bundle b = new Bundle();

                    /*
                     * Warning with Error FAILED BINDED TRANSACTION: it
                     * happens When the transfer of "extras" out of memory.
                     * in This case, when images are sent in intent.
                     */
                    b.putSerializable(ImageDetails.KEY_THUMBNAIL_DATA, feedReader.getListThumbnailData());
                    b.putSerializable(ImageDetails.KEY_THUMBNAIL_KEYS, feedReader.getListThumbnailKeys());
                    b.putInt(ImageDetails.KEY_THUMBNAIL_ACTUAL_KEY, key);
                    in.putExtras(b);
                    startActivity(in);
                }

            }
        }
    };
    IntentFilter filter = new IntentFilter();
    filter.addAction(ACTION_IMAGE_CLICK);
    registerReceiver(mReceiver, filter);

    /* Load data from Instagram */
    cargarFeedReader();
}

From source file:com.c4fcm.actionpath.MainActivity.java

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

    // Set the pattern for the latitude and longitude format
    String latLngPattern = getString(R.string.lat_lng_pattern);

    // Set the format for latitude and longitude
    mLatLngFormat = new DecimalFormat(latLngPattern);

    // Localize the format
    mLatLngFormat.applyLocalizedPattern(mLatLngFormat.toLocalizedPattern());

    // Set the pattern for the radius format
    String radiusPattern = getString(R.string.radius_pattern);

    // Set the format for the radius
    mRadiusFormat = new DecimalFormat(radiusPattern);

    // Localize the pattern
    mRadiusFormat.applyLocalizedPattern(mRadiusFormat.toLocalizedPattern());

    // Create a new broadcast receiver to receive updates from the listeners and service
    mBroadcastReceiver = new GeofenceSampleReceiver();

    // Create a new broadcast receiver to receive updates from SynchronizeDataService
    mSyncDataReceiver = new SynchronizeDataReceiver();

    // Create an intent filter for the broadcast receiver
    mIntentFilter = new IntentFilter();

    // Action for broadcast Intents that report successful addition of geofences
    mIntentFilter.addAction(GeofenceUtils.ACTION_GEOFENCES_ADDED);

    // Action for broadcast Intents that report successful removal of geofences
    mIntentFilter.addAction(GeofenceUtils.ACTION_GEOFENCES_REMOVED);

    // Action for broadcast Intents containing various types of geofencing errors
    mIntentFilter.addAction(GeofenceUtils.ACTION_GEOFENCE_ERROR);

    // All Location Services sample apps use this category
    mIntentFilter.addCategory(GeofenceUtils.CATEGORY_LOCATION_SERVICES);

    mSyncIntentFilter = new IntentFilter();
    mSyncIntentFilter.addAction(GeofenceUtils.UPDATE_GEOFENCES);

    // Instantiate a new geofence storage area
    Context ctx = this.getApplicationContext();
    Log.i("MainActivityContext", ctx.toString());
    mPrefs = new SurveyGeofenceStore(ctx);

    // Instantiate the current List of geofences
    mCurrentGeofences = new ArrayList<Geofence>();

    // Instantiate a Geofence requester
    mGeofenceRequester = new GeofenceRequester(this);

    // Instantiate a Geofence remover
    mGeofenceRemover = new GeofenceRemover(this);

    //instantiate list of geofences
    mUIGeofences = new ArrayList<SurveyGeofence>();

    //  addGeoFences();

    //disallow the title bar from appearing
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);

    //Remove notification bar
    //this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

    // Attach to the main UI
    setContentView(R.layout.activity_main);

    Log.i("MainActivity.OnCreate", "synchronizeDataService");
    synchronizeDataService();//www .  j  a  v a  2 s .  co  m

}

From source file:com.amazon.android.contentbrowser.helper.AuthHelper.java

/**
 * Constructor./*w  w w .jav a 2s  . c  o  m*/
 *
 * @param context        Context.
 * @param contentBrowser Content browser.
 */
public AuthHelper(Context context, ContentBrowser contentBrowser) {

    mAppContext = context.getApplicationContext();
    mContentBrowser = contentBrowser;

    // Get default Auth interface without creating a new one.
    try {
        mIAuthentication = (IAuthentication) ModuleManager.getInstance()
                .getModule(IAuthentication.class.getSimpleName()).getImpl(true);
    } catch (Exception e) {
        Log.e(TAG, "No Auth Interface interface attached.", e);
    }

    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(LogoutSettingsFragment.LOGOUT_BUTTON_BROADCAST_INTENT_ACTION);
    LocalBroadcastManager.getInstance(mAppContext).registerReceiver(mLocalBroadcastReceiver, intentFilter);
    //AuthHelper is initialized, broadcast initial authentication status
    isAuthenticated().subscribe(isAuthenticatedResultBundle -> {
        boolean result = isAuthenticatedResultBundle.getBoolean(AuthHelper.RESULT);
        broadcastAuthenticationStatus(result);
    });
}

From source file:name.gumartinm.weather.information.fragment.overview.OverviewFragment.java

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

    this.mReceiver = new BroadcastReceiver() {

        @Override/*from   www  . j a  va 2  s.  co m*/
        public void onReceive(final Context context, final Intent intent) {
            final String action = intent.getAction();
            if (action.equals(BROADCAST_INTENT_ACTION)) {
                final Forecast forecastRemote = (Forecast) intent.getSerializableExtra("forecast");

                // 1. Check conditions. They must be the same as the ones that triggered the AsyncTask.
                final DatabaseQueries query = new DatabaseQueries(context.getApplicationContext());
                final WeatherLocation weatherLocation = query.queryDataBase();
                final PermanentStorage store = new PermanentStorage(context.getApplicationContext());
                final Forecast forecast = store.getForecast();

                if (forecast == null
                        || !OverviewFragment.this.isDataFresh(weatherLocation.getLastForecastUIUpdate())) {

                    if (forecastRemote != null) {
                        // 2. Update UI.
                        OverviewFragment.this.updateUI(forecastRemote);

                        // 3. Update Data.
                        store.saveForecast(forecastRemote);
                        weatherLocation.setLastForecastUIUpdate(new Date());
                        query.updateDataBase(weatherLocation);

                        // 4. Show list.
                        OverviewFragment.this.setListShownNoAnimation(true);
                    } else {
                        // Empty list and show error message (see setEmptyText in onCreate)
                        OverviewFragment.this.setListAdapter(null);
                        OverviewFragment.this.setListShownNoAnimation(true);
                    }
                }
            }
        }
    };

    // Register receiver
    final IntentFilter filter = new IntentFilter();
    filter.addAction(BROADCAST_INTENT_ACTION);
    LocalBroadcastManager.getInstance(this.getActivity().getApplicationContext())
            .registerReceiver(this.mReceiver, filter);

    final DatabaseQueries query = new DatabaseQueries(this.getActivity().getApplicationContext());
    final WeatherLocation weatherLocation = query.queryDataBase();
    if (weatherLocation == null) {
        // Nothing to do.
        // Empty list and show error message (see setEmptyText in onCreate)
        this.setListAdapter(null);
        this.setListShownNoAnimation(true);
        return;
    }

    final PermanentStorage store = new PermanentStorage(this.getActivity().getApplicationContext());
    final Forecast forecast = store.getForecast();

    if (forecast != null && this.isDataFresh(weatherLocation.getLastForecastUIUpdate())) {
        this.updateUI(forecast);
    } else {
        // Load remote data (aynchronous)
        // Gets the data from the web.
        this.setListShownNoAnimation(false);
        final OverviewTask task = new OverviewTask(this.getActivity().getApplicationContext(),
                new CustomHTTPClient(AndroidHttpClient.newInstance(this.getString(R.string.http_client_agent))),
                new ServiceForecastParser(new JPOSForecastParser()));

        task.execute(weatherLocation.getLatitude(), weatherLocation.getLongitude());
    }
}