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(Parcel source) 

Source Link

Usage

From source file:com.hypodiabetic.happ.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

    activity = this;
    super.onCreate(savedInstanceState);
    Fabric.with(this, new Crashlytics());
    ins = this;/*from   w w w.  ja va  2s  .c o m*/
    PreferenceManager.setDefaultValues(this, R.xml.pref_aps, false); //Sets default APS Preferences if the user has not

    //xdrip start
    prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    checkEula();

    startService(new Intent(getApplicationContext(), DataCollectionService.class));

    PreferenceManager.setDefaultValues(this, R.xml.pref_general, false);
    PreferenceManager.setDefaultValues(this, R.xml.pref_bg_notification, false);
    //xdrip end

    setContentView(R.layout.activity_main);
    extendedGraphBuilder = new ExtendedGraphBuilder(this);

    //Setup menu
    tickWhite = getDrawable(R.drawable.checkbox_marked_circle);
    clockWhite = getDrawable(R.drawable.clock);
    tickWhite.setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_ATOP);
    clockWhite.setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_ATOP);

    insulinIntegrationApp_status = (TextView) findViewById(R.id.insulinIntegrationApp_status);
    insulinIntegrationApp_icon = (ImageView) findViewById(R.id.insulinIntegrationApp_icon);
    mDrawerList = (ListView) findViewById(R.id.navList);
    String[] osArray = { "Cancel Temp", "Settings", "Integration Report" };
    mAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, osArray);
    mDrawerList.setAdapter(mAdapter);
    mDrawerList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            switch (position) {
            case 0:
                pumpAction.cancelTempBasal(MainActivity.activity);
                break;
            case 1:
                startActivity(new Intent(getApplicationContext(), SettingsActivity.class));
                break;
            case 2:
                startActivity(new Intent(getApplicationContext(), Integration_Report.class));
                break;
            }
            mDrawerLayout.closeDrawers();
        }
    });
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerLinear = (LinearLayout) findViewById(R.id.left_drawer);
    mActivityTitle = getTitle().toString();
    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.drawer_open,
            R.string.drawer_close) {
        /** Called when a drawer has settled in a completely open state. */
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
            SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(MainActivity.getInstace());
            Date now = new Date();
            Profile p = new Profile(now, MainActivity.getInstace());
            //Local device based Integrations
            String insulin_Integration_App = prefs.getString("insulin_integration", "");

            //Insulin Integration App, try and connect
            if (!insulin_Integration_App.equals("")) {
                InsulinIntegrationApp insulinIntegrationApp = new InsulinIntegrationApp(
                        MainActivity.getInstace(), insulin_Integration_App, "TEST");
                insulinIntegrationApp.connectInsulinTreatmentApp();
                insulinIntegrationApp_status.setText("Connecting...");
                insulinIntegrationApp_icon.setBackground(clockWhite);

                //listens out for connection
                insulinIntegrationAppUpdate = new BroadcastReceiver() {
                    @Override
                    public void onReceive(Context context, Intent intent) {
                        insulinIntegrationApp_status.setText(intent.getStringExtra("MSG"));
                        insulinIntegrationApp_icon.setBackground(tickWhite);

                    }
                };
                LocalBroadcastManager.getInstance(MainActivity.getInstace()).registerReceiver(
                        insulinIntegrationAppUpdate, new IntentFilter("INSULIN_INTEGRATION_TEST"));
            } else {
                insulinIntegrationApp_status.setText("No app selected or not in Closed Loop");
                insulinIntegrationApp_icon.setBackgroundResource(R.drawable.alert_circle);
            }
        }

        /** Called when a drawer has settled in a completely closed state. */
        public void onDrawerClosed(View view) {
            super.onDrawerClosed(view);
            invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
        }
    };

    toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(true);
    mDrawerToggle.syncState();
    mDrawerToggle.setDrawerIndicatorEnabled(true);
    mDrawerLayout.setDrawerListener(mDrawerToggle);

    // Create the adapter that will return a fragment for each of the 4 primary sections of the app.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) this.findViewById(R.id.pager);
    mViewPager.setAdapter(mSectionsPagerAdapter);
    //mViewPager.setOffscreenPageLimit(4);                                                        //Do not destroy any Fragments, // TODO: 14/09/2015 casues an issue with bvb chart rendering, not sure why
    //Build Fragments
    openAPSFragmentObject = new openAPSFragment();
    iobcobActiveFragmentObject = new iobcobActiveFragment();
    iobcobFragmentObject = new iobcobFragment();
    basalvsTempBasalObject = new basalvsTempBasalFragment();

    //Updates notifications every 60 seconds
    updateEvery60Seconds = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            APSResult apsResult = APSResult.last();
            Notifications.updateCard(context, apsResult);
        }
    };
    registerReceiver(updateEvery60Seconds, new IntentFilter(Intent.ACTION_TIME_TICK));

}

From source file:com.owncloud.android.ui.fragment.FileDetailFragment.java

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

    mDownloadFinishReceiver = new DownloadFinishReceiver();
    IntentFilter filter = new IntentFilter(FileDownloader.DOWNLOAD_FINISH_MESSAGE);
    getActivity().registerReceiver(mDownloadFinishReceiver, filter);

    mUploadFinishReceiver = new UploadFinishReceiver();
    filter = new IntentFilter(FileUploader.UPLOAD_FINISH_MESSAGE);
    getActivity().registerReceiver(mUploadFinishReceiver, filter);

    mPreview = (ImageView) mView.findViewById(R.id.fdPreview);
}

From source file:gov.nasa.arc.geocam.geocam.GeoCamMobile.java

@Override
public void onResume() {
    super.onResume();
    Log.d(DEBUG_ID, "GeoCamMobile::onResume called");

    mForeground.foreground();// w  w w. j a v  a 2  s . c  o m

    mServiceBound = bindService(new Intent(this, GeoCamService.class), mServiceConn, Context.BIND_AUTO_CREATE);
    if (!mServiceBound) {
        Log.e(DEBUG_ID, "GeoCamMobile::onResume - error binding to service");
    }

    IntentFilter filter = new IntentFilter(GeoCamMobile.LOCATION_CHANGED);
    this.registerReceiver(mLocationReceiver, filter);

    LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
    if (!locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
        showDialog(DIALOG_GPS_OFF_ID);
    }
}

From source file:ca.mcgill.hs.serv.LogFileUploaderService.java

@Override
public synchronized void onStart(final Intent intent, final int startId) {
    // Update the file list
    updateFileList();/*from   ww w  .  j ava  2  s  . c  o m*/

    // If there are no files, return.
    if (fileList.size() == 0 && !started) {
        makeToast(getResources().getString(R.string.uploader_no_new_files), Toast.LENGTH_SHORT);
        return;
    }

    // If it was already started, return. Else, continue.
    if (started) {
        return;
    }

    // At this point we consider the service to be started.
    started = true;

    registerReceiver(wifiOnlyPrefChanged, new IntentFilter(WIFI_ONLY_CHANGED_INTENT));
    registerReceiver(autoPrefChanged, new IntentFilter(AUTO_UPLOAD_CHANGED_INTENT));

    wifiMgr = (WifiManager) getSystemService(Context.WIFI_SERVICE);
    wifiInfo = wifiMgr.getConnectionInfo();

    // Register completion receiver
    registerReceiver(completionReceiver, new IntentFilter(UPLOAD_COMPLETE_INTENT));

    // Connect to a network
    setUpConnection();

    notificationMgr = (NotificationManager) getSystemService(NOTIFICATION_STRING);
    notificationMgr.cancel(NOTIFICATION_ID);

    final int icon = R.drawable.notification_icon;
    final String tickerText = getResources().getString(R.string.notification_ticker);
    final String contentTitle = getResources().getString(R.string.notification_upload_title);
    final String contentText = getResources().getString(R.string.notification_upload_text);

    final Notification n = new Notification(icon, tickerText, System.currentTimeMillis());

    final Intent i = new Intent(this, HSService.class);
    n.setLatestEventInfo(this, contentTitle, contentText,
            PendingIntent.getActivity(this.getBaseContext(), 0, i, PendingIntent.FLAG_CANCEL_CURRENT));

    notificationMgr.notify(NOTIFICATION_ID, n);

    filesUploaded = 0;
    uploadFiles();
}

From source file:com.bt.heliniumstudentapp.UpdateClass.java

protected static void downloadAPK() {
    File oldUpdate = new File(Environment.getExternalStorageDirectory() + "/" + Environment.DIRECTORY_DOWNLOADS
            + "/heliniumstudentapp.apk");
    if (oldUpdate.exists()) //noinspection ResultOfMethodCallIgnored
        oldUpdate.delete();/*  w ww.j  a  v a 2 s. c o m*/

    if (MainActivity.isOnline()) {
        DownloadManager.Request request;

        request = new DownloadManager.Request(Uri.parse(HeliniumStudentApp.URL_UPDATE_RELEASE));

        request.setTitle(context.getString(R.string.app_name) + " " + versionName);
        request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "/heliniumstudentapp.apk");

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
            request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);

        ((DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE)).enqueue(request);

        context.registerReceiver(new BroadcastReceiver() {

            @Override
            public void onReceive(Context context, Intent intent) {
                final Intent install = new Intent(Intent.ACTION_VIEW);
                install.setDataAndType(
                        Uri.fromFile(new File(Environment.getExternalStorageDirectory() + "/"
                                + Environment.DIRECTORY_DOWNLOADS + "/heliniumstudentapp.apk")),
                        "application/vnd.android.package-archive");
                context.startActivity(install);
            }
        }, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));
    } else {
        Toast.makeText(context, R.string.error_conn_no, Toast.LENGTH_SHORT).show();
    }
}

From source file:gov.nasa.arc.geocam.geocam.CameraActivity.java

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

    mServiceBound = bindService(new Intent(this, GeoCamService.class), mServiceConn, Context.BIND_AUTO_CREATE);
    if (!mServiceBound) {
        Log.e(GeoCamMobile.DEBUG_ID, "CameraActivity::onResume - error binding to service");
    }//w  w w .  j  a  v  a 2 s .  c om

    mForeground.foreground();

    mSensorManager.registerListener(mSensorListener, mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER),
            SensorManager.SENSOR_DELAY_GAME);
    mSensorManager.registerListener(mSensorListener,
            mSensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD), SensorManager.SENSOR_DELAY_GAME);

    mLatText.setText("Lat: unavailable");
    mLonText.setText("Lon: unavailable");

    IntentFilter filter = new IntentFilter(GeoCamMobile.LOCATION_CHANGED);
    this.registerReceiver(mLocationReceiver, filter);

    if (getResources().getConfiguration().hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO) {
        showDialog(DIALOG_HIDE_KEYBOARD);
    }

    // Unset focus and picture status flags when returning from another activity
    mLensIsFocused = false;
    mPictureTaken = false;
}

From source file:com.DGSD.DGUtils.Http.BetterHttp.java

public static void setContext(Context context) {
    if (appContext != null) {
        return;//w  w  w.j  ava2  s  . c  o  m
    }
    appContext = context.getApplicationContext();
    appContext.registerReceiver(new ConnectionChangedBroadcastReceiver(),
            new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
}

From source file:com.att.android.arodatacollector.activities.AROCollectorHomeActivity.java

/**
* method to register the receiver that listens to analyzer timeout
*///from   w  w  w. j  av  a 2 s. c  om
private void registerAnalyzerCloseCmdReceiver() {
    AROLogger.d(TAG, "registering analyzerTimeOutReceiver");
    registerReceiver(analyzerCloseCmdReceiver, new IntentFilter(AROCollectorUtils.ANALYZER_CLOSE_CMD_INTENT));
}

From source file:com.mobicage.rogerthat.registration.RegistrationActivity2.java

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

    T.UI();//w ww . j a  v  a2s . com
    createWorkerThread();
    mUIHandler = new Handler();
    T.setUIThread("RegistrationProcedureActivity.onCreate()");
    setTitle(R.string.registration_title);

    mHttpClient = HTTPUtil.getHttpClient(HTTP_TIMEOUT, HTTP_RETRY_COUNT);

    final IntentFilter filter = new IntentFilter(MainService.INTENT_BEACON_SERVICE_CONNECTED);
    filter.addAction(RegistrationWizard2.INTENT_GOT_BEACON_REGIONS);
    filter.addAction(Intent.ACTION_SCREEN_OFF);
    filter.addAction(Intent.ACTION_SCREEN_ON);
    registerReceiver(mBroadcastReceiver, filter);

    startRegistrationService();

    // TODO: This has to be improved.
    // If the app relies on GCM the user should not be able to register.
    if (CloudConstants.USE_GCM_KICK_CHANNEL)
        GoogleServicesUtils.checkPlayServices(this);

}