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.t2.compassionMeditation.Graphs1Activity.java

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

    mIsActive = true;/*from w  w  w  . j a va2  s.  c  om*/

    // we need to register a SPINEListener implementation to the SPINE manager instance
    // to receive sensor node data from the Spine server
    // (I register myself since I'm a SPINEListener implementation!)
    mManager.addListener(this);

    Log.i(TAG, this.getClass().getSimpleName() + ".onStart()");

    // Set up filter intents so we can receive broadcasts
    IntentFilter filter = new IntentFilter();
    filter.addAction("com.t2.biofeedback.service.status.BROADCAST");
    this.registerReceiver(this.mCommandReceiver, filter);

    int displaySampleTime = 1000;
    String s = SharedPref.getString(this, "display_sample_rate", "1");
    mDisplaySampleRate = Integer.parseInt(s);

    switch (mDisplaySampleRate) {
    default:
    case 1:
        displaySampleTime = 1000;
        Log.d(TAG, "Setting display sample rate to " + mDisplaySampleRate + " Hz");
        break;
    case 10:
        displaySampleTime = 100;
        Log.d(TAG, "Setting display sample rate to " + mDisplaySampleRate + " Hz");
        break;
    case 100:
        displaySampleTime = 10;
        Log.d(TAG, "Setting display sample rate to " + mDisplaySampleRate + " Hz");
        break;
    case 9999:
        displaySampleTime = 9999;
        Log.d(TAG, "Setting display sample rate to match sensor sample rate");
        break;
    }

    if (mDisplaySampleRate != 9999) {
        // Set up a timer to do graphical updates
        mDataUpdateTimer = new Timer();
        mDataUpdateTimer.schedule(new TimerTask() {
            @Override
            public void run() {
                TimerMethod();
            }

        }, 0, displaySampleTime);
    }

    // Set up a timer for GSR average reporting (10 seconds

    mRespRateAverageTimer = new Timer();
    mRespRateAverageTimer.schedule(new TimerTask() {
        @Override
        public void run() {
            respRateAverageMethod();
        }

    }, 0, 10000);

    if (mAntHrmEnabled) {
        mAntServiceBound = bindService(new Intent(this, ANTPlusService.class), mConnection, BIND_AUTO_CREATE);
    }

}

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

@Override
public void onStart() {
    super.onStart();
    final IntentFilter filter = new IntentFilter(BROADCAST_FRIENDSHIP_CHANGED);
    filter.addAction(BROADCAST_BLOCKSTATE_CHANGED);
    filter.addAction(BROADCAST_PROFILE_UPDATED);
    registerReceiver(mStatusReceiver, filter);
    updateUserColor();/*from   www  .  j  ava 2 s  .  c om*/
}

From source file:com.freeme.filemanager.view.FileViewFragment.java

public void init() {
    long time1 = System.currentTimeMillis();
    //Debug.startMethodTracing("file_view");
    ViewStub stub = (ViewStub) mRootView.findViewById(R.id.viewContaniner);
    stub.setLayoutResource(R.layout.file_explorer_list);
    stub.inflate();//from www. j  a v  a 2  s. c o  m
    ActivitiesManager.getInstance().registerActivity(ActivitiesManager.ACTIVITY_FILE_VIEW, mActivity);

    mFileCagetoryHelper = new FileCategoryHelper(mActivity);
    mFileViewInteractionHub = new FileViewInteractionHub(this, 1);
    // */ modify by droi liuhaoran for stop run
    /*/ Added by tyd wulianghuan 2013-12-12
    mCleanUpDatabaseHelper = new CleanUpDatabaseHelper(mActivity);
    mDatabase = mCleanUpDatabaseHelper.openDatabase();
    mFolderNameMap = new HashMap<String, String>();
    //*/

    // */add by droi liuhaoran for get Sd listener on 20160419
    mApplication = (FileManagerApplication) mActivity.getApplication();
    // */

    // notifyFileChanged();
    Intent intent = mActivity.getIntent();
    String action = intent.getAction();
    if (!TextUtils.isEmpty(action)
            && (action.equals(Intent.ACTION_PICK) || action.equals(Intent.ACTION_GET_CONTENT))) {
        mFileViewInteractionHub.setMode(Mode.Pick);

        boolean pickFolder = intent.getBooleanExtra(PICK_FOLDER, false);
        if (!pickFolder) {
            String[] exts = intent.getStringArrayExtra(EXT_FILTER_KEY);
            if (exts != null) {
                mFileCagetoryHelper.setCustomCategory(exts);
            }
        } else {
            mFileCagetoryHelper.setCustomCategory(new String[] {} /*
                                                                  * folder
                                                                  * only
                                                                  */);
            mRootView.findViewById(R.id.pick_operation_bar).setVisibility(View.VISIBLE);

            mRootView.findViewById(R.id.button_pick_confirm).setOnClickListener(new OnClickListener() {
                public void onClick(View v) {
                    try {
                        Intent intent = Intent.parseUri(mFileViewInteractionHub.getCurrentPath(), 0);
                        mActivity.setResult(Activity.RESULT_OK, intent);
                        mActivity.finish();
                    } catch (URISyntaxException e) {
                        e.printStackTrace();
                    }
                }
            });

            mRootView.findViewById(R.id.button_pick_cancel).setOnClickListener(new OnClickListener() {
                public void onClick(View v) {
                    mActivity.finish();
                }
            });
        }
    } else {
        mFileViewInteractionHub.setMode(Mode.View);
    }
    mVolumeSwitch = (ImageButton) mRootView.findViewById(R.id.volume_navigator);
    updateVolumeSwitchState();
    mGalleryNavigationBar = (RelativeLayout) mRootView.findViewById(R.id.gallery_navigation_bar);
    mVolumeSwitch.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View arg0) {
            int visibility = getVolumesListVisibility();
            if (visibility == View.GONE) {
                buildVolumesList();
                showVolumesList(true);
            } else if (visibility == View.VISIBLE) {
                showVolumesList(false);
            }
        }

    });
    mFileListView = (ListView) mRootView.findViewById(R.id.file_path_list);
    mFileIconHelper = new FileIconHelper(mActivity);
    mAdapter = new FileListAdapter(mActivity, R.layout.file_browser_item, mFileNameList,
            mFileViewInteractionHub, mFileIconHelper);

    boolean baseSd = intent.getBooleanExtra(GlobalConsts.KEY_BASE_SD,
            !FileExplorerPreferenceActivity.isReadRoot(mActivity));
    Log.i(LOG_TAG, "baseSd = " + baseSd);

    String rootDir = intent.getStringExtra(ROOT_DIRECTORY);
    if (!TextUtils.isEmpty(rootDir)) {
        if (baseSd && this.sdDir.startsWith(rootDir)) {
            rootDir = this.sdDir;
        }
    } else {
        rootDir = baseSd ? this.sdDir : GlobalConsts.ROOT_PATH;
    }

    String currentDir = FileExplorerPreferenceActivity.getPrimaryFolder(mActivity);
    Uri uri = intent.getData();
    if (uri != null) {
        if (baseSd && this.sdDir.startsWith(uri.getPath())) {
            currentDir = this.sdDir;
        } else {
            currentDir = uri.getPath();
        }
    }
    initVolumeState();
    mBackspaceExit = (uri != null) && (TextUtils.isEmpty(action)
            || (!action.equals(Intent.ACTION_PICK) && !action.equals(Intent.ACTION_GET_CONTENT)));

    mFileListView.setAdapter(mAdapter);
    IntentFilter intentFilter = new IntentFilter();
    // add by xueweili for get sdcard
    intentFilter.setPriority(1000);

    /*
     * intentFilter.addAction(Intent.ACTION_MEDIA_MOUNTED);
     * intentFilter.addAction(Intent.ACTION_MEDIA_UNMOUNTED);
     * intentFilter.addAction(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
     * intentFilter.addAction(Intent.ACTION_MEDIA_SCANNER_FINISHED);
     * intentFilter.addAction(Intent.ACTION_MEDIA_EJECT);
     */
    if (!mReceiverTag) {
        mReceiverTag = true;
        intentFilter.addAction(GlobalConsts.BROADCAST_REFRESH);
        intentFilter.addDataScheme("file");
        mActivity.registerReceiver(mReceiver, intentFilter);
    }

    // */add by droi liuhaoran for get Sd listener on 20160419
    mApplication.addSDCardChangeListener(this);
    // */

    setHasOptionsMenu(true);

    // add by mingjun for load file
    mRootView.addOnLayoutChangeListener(new OnLayoutChangeListener() {

        @Override
        public void onLayoutChange(View arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6,
                int arg7, int arg8) {
            isLayout = arg1;
        }
    });
    loadDialog = new ProgressDialog(mRootView.getContext());
}

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

/** Called when the activity is first created. */
@Override/* w w w.  java  2 s.  c o  m*/
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    setBlockNumber();
    // Get USB manager
    mManager = (UsbManager) getSystemService(Context.USB_SERVICE);

    // Initialize reader
    mReader = new Reader(mManager);
    mReader.setOnStateChangeListener(new OnStateChangeListener() {

        @Override
        public void onStateChange(int slotNum, int prevState, int currState) {

            if (prevState < Reader.CARD_UNKNOWN || prevState > Reader.CARD_SPECIFIC) {
                prevState = Reader.CARD_UNKNOWN;
            }

            if (currState < Reader.CARD_UNKNOWN || currState > Reader.CARD_SPECIFIC) {
                currState = Reader.CARD_UNKNOWN;
            }

            // Create output string
            final String outputString = "Slot " + slotNum + ": " + stateStrings[prevState] + " -> "
                    + stateStrings[currState];
            final String state = stateStrings[currState];

            // Show output
            runOnUiThread(new Runnable() {

                @Override
                public void run() {
                    logMsg(outputString);
                    if (state.equals("Present")) {
                        mAuthenticateRead = false;
                        if (mReadMode) {
                            setBlockNumber();
                            try {

                                mTaskReadStart = false;
                                mTaskStart = false;
                                mTaskWriteStart = false;

                                TimeRead = 0;
                                TimeWrite = 0;
                                timeEnd = 0;
                                initStart = 0;
                                nowRead = 0;
                                nowWrite = 0;
                                nowStart = 0;

                                mBlockAuthen = true;
                                mReadMode = true;
                                mWriteMode = false;

                                System.gc();

                                reader();

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

                        }

                    }
                }
            });
        }
    });

    // Register receiver for USB permission
    mPermissionIntent = PendingIntent.getBroadcast(this, 0, new Intent(ACTION_USB_PERMISSION), 0);
    IntentFilter filter = new IntentFilter();
    filter.addAction(ACTION_USB_PERMISSION);
    filter.addAction(UsbManager.ACTION_USB_DEVICE_DETACHED);
    registerReceiver(mReceiver, filter);

    sdf = new SimpleDateFormat("mm:ss.SSS");

    mResponseTextView = (TextView) findViewById(R.id.main_text_view_response);
    mResponseTextView.setMovementMethod(new ScrollingMovementMethod());
    mResponseTextView.setMaxLines(MAX_LINES);
    mResponseTextView.setText("");

    mTextType = (TextView) findViewById(R.id.textType);
    mReadTime = (TextView) findViewById(R.id.textViewReadSet);
    mWriteTime = (TextView) findViewById(R.id.textViewWriteSet);
    mEndTime = (TextView) findViewById(R.id.textViewEndSet);

    mWriteType = (EditText) findViewById(R.id.EditText_writeDataType);
    mQty = (EditText) findViewById(R.id.QTY);

    formatter = new DecimalFormat("###,###,###.##");

    mWriteDataBalanceEditText = (EditText) findViewById(R.id.EditText_writeDataBalance);
    mWriteDataIdEditText = (EditText) findViewById(R.id.EditText_writeDataId);

    mTextMode = (TextView) findViewById(R.id.textMode);
    mTextBalance = (TextView) findViewById(R.id.BALANCE);

    mTextId = (TextView) findViewById(R.id.textId);
    // Initialize reader spinner

    for (UsbDevice device : mManager.getDeviceList().values()) {
        if (mReader.isSupported(device)) {
            mReaderAdapterX = device.getDeviceName().toString();
        }
    }
    // Initialize open button
    mOpenButton = (Button) findViewById(R.id.btnStart);
    mOpenButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            getDevices();
            // Disable open button
            mOpenButton.setEnabled(false);

        }
    });

    // Initialize close button
    mCloseButton = (Button) findViewById(R.id.btnStop);
    mCloseButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            // Disable buttons

            mOpenButton.setEnabled(false);
            // Clear slot items

            // Close reader
            logMsg("Closing reader...");
            new CloseTask().execute();
        }
    });

    mWriteData = (Button) findViewById(R.id.btnWrite);
    mWriteData.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (mAuthenticateRead == true) {
                mBlockWrite = true;
                setBlockNumber();
                mReadMode = false;
                mWriteMode = true;
                mTextMode.setText("- W R I T E -");
                //               mReadData.setVisibility(View.VISIBLE);
                //               mWriteData.setVisibility(View.GONE);
                try {
                    writer();
                } catch (Exception e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            } else {
                Toast.makeText(getApplicationContext(), "Please Authenticate first", Toast.LENGTH_SHORT).show();
            }

        }
    });

    mReadData = (Button) findViewById(R.id.btnRead);
    mReadData.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            mBlockAuthen = true;
            setBlockNumber();
            mReadMode = true;
            mWriteMode = false;
            mTextMode.setText("- R E A D -");
            //            mReadData.setVisibility(View.GONE);
            //            mWriteData.setVisibility(View.VISIBLE);

        }
    });

    // PIN verification command (ACOS3)
    byte[] pinVerifyData = { (byte) 0x80, 0x20, 0x06, 0x00, 0x08, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
            (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF };

    // Initialize PIN verify structure (ACOS3)
    mPinVerify.setTimeOut(0);
    mPinVerify.setTimeOut2(0);
    mPinVerify.setFormatString(0);
    mPinVerify.setPinBlockString(0x08);
    mPinVerify.setPinLengthFormat(0);
    mPinVerify.setPinMaxExtraDigit(0x0408);
    mPinVerify.setEntryValidationCondition(0x03);
    mPinVerify.setNumberMessage(0x01);
    mPinVerify.setLangId(0x0409);
    mPinVerify.setMsgIndex(0);
    mPinVerify.setTeoPrologue(0, 0);
    mPinVerify.setTeoPrologue(1, 0);
    mPinVerify.setTeoPrologue(2, 0);
    mPinVerify.setData(pinVerifyData, pinVerifyData.length);

    // PIN modification command (ACOS3)
    byte[] pinModifyData = { (byte) 0x80, 0x24, 0x00, 0x00, 0x08, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
            (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF };

    // Initialize PIN modify structure (ACOS3)
    mPinModify.setTimeOut(0);
    mPinModify.setTimeOut2(0);
    mPinModify.setFormatString(0);
    mPinModify.setPinBlockString(0x08);
    mPinModify.setPinLengthFormat(0);
    mPinModify.setInsertionOffsetOld(0);
    mPinModify.setInsertionOffsetNew(0);
    mPinModify.setPinMaxExtraDigit(0x0408);
    mPinModify.setConfirmPin(0x01);
    mPinModify.setEntryValidationCondition(0x03);
    mPinModify.setNumberMessage(0x02);
    mPinModify.setLangId(0x0409);
    mPinModify.setMsgIndex1(0);
    mPinModify.setMsgIndex2(0x01);
    mPinModify.setMsgIndex3(0);
    mPinModify.setTeoPrologue(0, 0);
    mPinModify.setTeoPrologue(1, 0);
    mPinModify.setTeoPrologue(2, 0);
    mPinModify.setData(pinModifyData, pinModifyData.length);

    // Initialize read key option
    mReadKeyOption.setTimeOut(0);
    mReadKeyOption.setPinMaxExtraDigit(0x0408);
    mReadKeyOption.setKeyReturnCondition(0x01);
    mReadKeyOption.setEchoLcdStartPosition(0);
    mReadKeyOption.setEchoLcdMode(0x01);

    // Disable buttons
    //      mCloseButton.setEnabled(false);
    //      mControlButton.setEnabled(false);

    // Hide input window
    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
}

From source file:com.halseyburgund.rwframework.core.RWService.java

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

    // create default configuration and tags
    configuration = new RWConfiguration(this);
    tags = new RWTags();

    // get default server url from resources and reset other critical vars
    mServerUrl = getString(R.string.rw_spec_server_url);
    mStreamUrl = null;/*from  ww w. j a va  2  s.co m*/

    // create a factory for actions
    mActionFactory = new RWActionFactory(this);

    // create a queue for actions
    RWActionQueue.instance().init(this);

    // listen to connectivity state broadcasts
    registerReceiver(connectivityReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
    // listen to own server calls success and failure broadcasts
    IntentFilter filter = createOperationsIntentFilter();
    filter.addAction(RW.CONFIGURATION_LOADED);
    filter.addAction(RW.NO_CONFIGURATION);
    registerReceiver(rwReceiver, filter);

    // setup for GPS callback
    RWLocationTracker.instance().init(this);
    RWLocationTracker.instance().addObserver(this);

    // setup a tracker for assets streamed by the server
    mAssetTracker = new RWStreamAssetsTracker(this);
}

From source file:com.t2.compassionMeditation.MeditationActivity.java

@Override
protected void onStart() {
    super.onStart();
    mIsActive = true;//from  w  w  w.j  a va  2s  .  c o m
    Log.i(TAG, this.getClass().getSimpleName() + ".onStart()");

    //      mPauseButton.setText("Start");
    mPauseButton.setImageResource(R.drawable.start);

    // Set up filter intents so we can receive broadcasts
    IntentFilter filter = new IntentFilter();
    filter.addAction("com.t2.biofeedback.service.status.BROADCAST");
    this.registerReceiver(this.mCommandReceiver, filter);

    // Set up a timer to do graphical updates
    mDataUpdateTimer = new Timer();
    mDataUpdateTimer.schedule(new TimerTask() {
        @Override
        public void run() {
            TimerMethod();
        }

    }, 0, 10);

    if (mMediaPlayer != null) {
        mMediaPlayer.stop();
    }

    int resource = 0;
    if (mAudioTrackResourceName.contains("Air Synth"))
        resource = R.raw.dave_luxton_air_synth_meditation;
    if (mAudioTrackResourceName.contains("Entity and Echo"))
        resource = R.raw.dave_luxton_entity_and_echo_meditation;
    if (mAudioTrackResourceName.contains("Starlit Lake"))
        resource = R.raw.dave_luxton_starlit_lake_meditation;

    if (resource != 0) {
        mMediaPlayer = MediaPlayer.create(this, resource);
        if (mMediaPlayer != null) {
            mMediaPlayer.start();
            mMediaPlayer.setLooping(true);
        }

    }

    if (mAntHrmEnabled) {
        mAntServiceBound = bindService(new Intent(this, ANTPlusService.class), mConnection, BIND_AUTO_CREATE);
    }
}

From source file:biz.bokhorst.xprivacy.ActivityApp.java

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

    final int userId = Util.getUserId(Process.myUid());

    // Check privacy service client
    if (!PrivacyService.checkClient())
        return;//from   w w w  . j  av a  2 s  .  c o m

    // Set layout
    setContentView(R.layout.restrictionlist);

    // Get arguments
    Bundle extras = getIntent().getExtras();
    if (extras == null) {
        finish();
        return;
    }

    int uid = extras.getInt(cUid);
    String restrictionName = (extras.containsKey(cRestrictionName) ? extras.getString(cRestrictionName) : null);
    String methodName = (extras.containsKey(cMethodName) ? extras.getString(cMethodName) : null);

    // Get app info
    mAppInfo = new ApplicationInfoEx(this, uid);
    if (mAppInfo.getPackageName().size() == 0) {
        finish();
        return;
    }

    // Set title
    setTitle(String.format("%s - %s", getString(R.string.app_name),
            TextUtils.join(", ", mAppInfo.getApplicationName())));

    // Handle info click
    ImageView imgInfo = (ImageView) findViewById(R.id.imgInfo);
    imgInfo.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            // Packages can be selected on the web site
            Util.viewUri(ActivityApp.this,
                    Uri.parse(String.format(ActivityShare.getBaseURL(ActivityApp.this) + "?package_name=%s",
                            mAppInfo.getPackageName().get(0))));
        }
    });

    // Display app name
    TextView tvAppName = (TextView) findViewById(R.id.tvApp);
    tvAppName.setText(mAppInfo.toString());

    // Background color
    if (mAppInfo.isSystem()) {
        LinearLayout llInfo = (LinearLayout) findViewById(R.id.llInfo);
        llInfo.setBackgroundColor(getResources().getColor(getThemed(R.attr.color_dangerous)));
    }

    // Display app icon
    final ImageView imgIcon = (ImageView) findViewById(R.id.imgIcon);
    imgIcon.setImageDrawable(mAppInfo.getIcon(this));

    // Handle icon click
    imgIcon.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            openContextMenu(imgIcon);
        }
    });

    // Display on-demand state
    final ImageView imgCbOnDemand = (ImageView) findViewById(R.id.imgCbOnDemand);
    if (PrivacyManager.isApplication(mAppInfo.getUid())
            && PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingOnDemand, true)) {
        boolean ondemand = PrivacyManager.getSettingBool(-mAppInfo.getUid(), PrivacyManager.cSettingOnDemand,
                false);
        imgCbOnDemand.setImageBitmap(ondemand ? getOnDemandCheckBox() : getOffCheckBox());

        imgCbOnDemand.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                boolean ondemand = !PrivacyManager.getSettingBool(-mAppInfo.getUid(),
                        PrivacyManager.cSettingOnDemand, false);
                PrivacyManager.setSetting(mAppInfo.getUid(), PrivacyManager.cSettingOnDemand,
                        Boolean.toString(ondemand));
                imgCbOnDemand.setImageBitmap(ondemand ? getOnDemandCheckBox() : getOffCheckBox());
                if (mPrivacyListAdapter != null)
                    mPrivacyListAdapter.notifyDataSetChanged();
            }
        });
    } else
        imgCbOnDemand.setVisibility(View.GONE);

    // Display restriction state
    swEnabled = (Switch) findViewById(R.id.swEnable);
    swEnabled.setChecked(
            PrivacyManager.getSettingBool(mAppInfo.getUid(), PrivacyManager.cSettingRestricted, true));
    swEnabled.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            PrivacyManager.setSetting(mAppInfo.getUid(), PrivacyManager.cSettingRestricted,
                    Boolean.toString(isChecked));
            if (mPrivacyListAdapter != null)
                mPrivacyListAdapter.notifyDataSetChanged();
            imgCbOnDemand.setEnabled(isChecked);
        }
    });
    imgCbOnDemand.setEnabled(swEnabled.isChecked());

    // Add context menu to icon
    registerForContextMenu(imgIcon);

    // Check if internet access
    if (!mAppInfo.hasInternet(this)) {
        ImageView imgInternet = (ImageView) findViewById(R.id.imgInternet);
        imgInternet.setVisibility(View.INVISIBLE);
    }

    // Check if frozen
    if (!mAppInfo.isFrozen(this)) {
        ImageView imgFrozen = (ImageView) findViewById(R.id.imgFrozen);
        imgFrozen.setVisibility(View.INVISIBLE);
    }

    // Display version
    TextView tvVersion = (TextView) findViewById(R.id.tvVersion);
    tvVersion.setText(TextUtils.join(", ", mAppInfo.getPackageVersionName(this)));

    // Display package name
    TextView tvPackageName = (TextView) findViewById(R.id.tvPackageName);
    tvPackageName.setText(TextUtils.join(", ", mAppInfo.getPackageName()));

    // Fill privacy list view adapter
    final ExpandableListView lvRestriction = (ExpandableListView) findViewById(R.id.elvRestriction);
    lvRestriction.setGroupIndicator(null);
    mPrivacyListAdapter = new RestrictionAdapter(R.layout.restrictionentry, mAppInfo, restrictionName,
            methodName);
    lvRestriction.setAdapter(mPrivacyListAdapter);
    if (restrictionName != null) {
        int groupPosition = new ArrayList<String>(PrivacyManager.getRestrictions(this).values())
                .indexOf(restrictionName);
        lvRestriction.expandGroup(groupPosition);
        lvRestriction.setSelectedGroup(groupPosition);
        if (methodName != null) {
            int childPosition = PrivacyManager.getHooks(restrictionName)
                    .indexOf(new Hook(restrictionName, methodName));
            lvRestriction.setSelectedChild(groupPosition, childPosition, true);
        }
    }

    // Listen for package add/remove
    IntentFilter iff = new IntentFilter();
    iff.addAction(Intent.ACTION_PACKAGE_REMOVED);
    iff.addDataScheme("package");
    registerReceiver(mPackageChangeReceiver, iff);
    mPackageChangeReceiverRegistered = true;

    // Up navigation
    getActionBar().setDisplayHomeAsUpEnabled(true);

    // Tutorial
    if (!PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingTutorialDetails, false)) {
        ((ScrollView) findViewById(R.id.svTutorialHeader)).setVisibility(View.VISIBLE);
        ((ScrollView) findViewById(R.id.svTutorialDetails)).setVisibility(View.VISIBLE);
    }
    View.OnClickListener listener = new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            ViewParent parent = view.getParent();
            while (!parent.getClass().equals(ScrollView.class))
                parent = parent.getParent();
            ((View) parent).setVisibility(View.GONE);
            PrivacyManager.setSetting(userId, PrivacyManager.cSettingTutorialDetails, Boolean.TRUE.toString());
        }
    };
    ((Button) findViewById(R.id.btnTutorialHeader)).setOnClickListener(listener);
    ((Button) findViewById(R.id.btnTutorialDetails)).setOnClickListener(listener);

    // Process actions
    if (extras.containsKey(cAction)) {
        NotificationManager notificationManager = (NotificationManager) getSystemService(
                Context.NOTIFICATION_SERVICE);
        notificationManager.cancel(mAppInfo.getUid());
        if (extras.getInt(cAction) == cActionClear)
            optionClear();
        else if (extras.getInt(cAction) == cActionSettings)
            optionSettings();
    }

    // Annotate
    Meta.annotate(this);
}

From source file:com.mobicage.rogerthat.plugins.messaging.BrandingMgr.java

public void initialize(ConfigurationProvider cfgProvider, MainService mainService) {
    T.UI();//from  w w w  .java  2  s .c o m
    mCfgProvider = cfgProvider;
    mMainService = mainService;
    mContext = mainService;

    List<BrandedItem> copy = new ArrayList<BrandingMgr.BrandedItem>();
    Collections.copy(mQueue, copy);
    for (BrandedItem item : copy)
        if (item.status != BrandedItem.STATUS_TODO)
            dequeue(item, false);

    mDownloaderThread = new HandlerThread("rogerthat_branding_worker");
    mDownloaderThread.start();
    Looper looper = mDownloaderThread.getLooper();
    mDownloaderHandler = new Handler(looper);

    IntentFilter filter = new IntentFilter();
    filter.addAction(Intent.ACTION_MEDIA_MOUNTED);
    filter.addAction(Intent.ACTION_MEDIA_REMOVED);
    filter.addAction(DownloadManager.ACTION_DOWNLOAD_COMPLETE);
    mContext.registerReceiver(mBroadcastReceiver, filter);
    initStorageSettings();

    mInitialized = true;

    mMainService.postOnBIZZHandler(new SafeRunnable() {
        @Override
        protected void safeRun() throws Exception {
            if (mMainService.getPluginDBUpdates(BrandingMgr.class).contains(MUST_DELETE_ATTACHMENTS_INTENT)) {
                synchronized (mLock) {
                    IOUtils.deleteRecursive(getAttachmentsRootDirectory());
                }
                mMainService.clearPluginDBUpdate(BrandingMgr.class, MUST_DELETE_ATTACHMENTS_INTENT);
            }
        }
    });
}

From source file:net.kidlogger.kidlogger.KLService.java

public void setupLogging() {
    // Set up GPS / Network logging      
    if (Settings.loggingGps(this)) {
        startGpsUpdates();/*w  w  w  . j av a  2s.c o m*/
        gpsOn = true;
    }

    // Set up WiFi logging
    if (Settings.loggingWifi(this)) {
        wifiReceiver = new WifiReceiver(this);
        registerReceiver(wifiReceiver, new IntentFilter(WifiManager.NETWORK_STATE_CHANGED_ACTION));
        wifiOn = true;
    }

    // Set up SMS logging
    if (Settings.loggingSms(this)) {
        smsObserver = new SmsObserver(this, handlering);
        IntentFilter smsFilter = new IntentFilter(SMS_RECEIVED);
        registerReceiver(smsObserver.inSms, smsFilter);
        smsOn = true;
    }

    // Set up Calls logging
    if (Settings.loggingCalls(this)) {
        IntentFilter callsFilter = new IntentFilter(TelephonyManager.ACTION_PHONE_STATE_CHANGED);

        callsReceiver = new CallsReceiver(this);
        registerReceiver(callsReceiver, callsFilter);
        callOn = true;
    }

    // Set up Idle logging
    IntentFilter idleFilter = new IntentFilter(Intent.ACTION_SCREEN_OFF);
    idleFilter.addAction(Intent.ACTION_USER_PRESENT);

    idleReceiver = new IdleReceiver(this);
    registerReceiver(idleReceiver, idleFilter);
    idleOn = true;
    /*if(Settings.loggingIdle(this)){
       IntentFilter idleFilter = new IntentFilter(Intent.ACTION_SCREEN_OFF);
       idleFilter.addAction(Intent.ACTION_USER_PRESENT);
               
       idleReceiver = new IdleReceiver(this);
       registerReceiver(idleReceiver, idleFilter);
       idleOn = true;
    }*/

    // Set up URL logging
    if (Settings.loggingUrl(this)) {
        urlObserver = new HistoryObserver(this, handlering);
        urlOn = true;
    }

    // Set up USB logging
    if (Settings.loggingUsb(this)) {
        IntentFilter usbFilter = new IntentFilter(Intent.ACTION_UMS_CONNECTED);
        usbFilter.addAction(Intent.ACTION_UMS_DISCONNECTED);

        usbReceiver = new UsbReceiver(this);
        registerReceiver(usbReceiver, usbFilter);
        usbOn = true;
    }

    // Set up Tasks logging
    if (logTask) {
        // Check if a new Application was started
        taskScan = new Runnable() {
            public void run() {
                new Thread(new Runnable() {
                    public void run() {
                        doScanTask();
                    }
                }).start();
                if (userPresent) {
                    handleTask.postDelayed(this, SCAN_TASK_TIME);
                    scanningTask = true;
                } else {
                    scanningTask = false;
                }
            }
        };
        handleTask.postDelayed(taskScan, SCAN_TASK_TIME);
        taskOn = true;
    }

    // Set up Clipboard logging
    if (logClip) {
        // Scan clipboard content, only first 30 characters
        clipboardScan = new Runnable() {
            public void run() {
                new Thread(new Runnable() {
                    public void run() {
                        doScanClipboard();
                    }
                }).start();
                if (userPresent) {
                    handleClipb.postDelayed(this, SCAN_CLIP_TIME);
                    scanningClip = true;
                } else {
                    scanningClip = false;
                }
            }
        };
        handleClipb.postDelayed(clipboardScan, SCAN_CLIP_TIME);
        clipOn = true;
    }

    // Set up Power logging
    if (Settings.loggingPower(this)) {
        IntentFilter powerFilter = new IntentFilter(Intent.ACTION_SHUTDOWN);

        powerReceiver = new ShutdownReceiver(this);
        registerReceiver(powerReceiver, powerFilter);
        powerOn = true;
    }

    // Set up Memory Card logging
    if (Settings.loggingMedia(this)) {
        IntentFilter mediaFilter = new IntentFilter(Intent.ACTION_MEDIA_REMOVED);
        mediaFilter.addAction(Intent.ACTION_MEDIA_BAD_REMOVAL);
        mediaFilter.addAction(Intent.ACTION_MEDIA_MOUNTED);
        mediaFilter.addAction(Intent.ACTION_MEDIA_UNMOUNTED);
        mediaFilter.addAction(Intent.ACTION_MEDIA_SHARED);
        mediaFilter.addDataScheme("file");

        mediaReceiver = new MediaReceiver(this);
        registerReceiver(mediaReceiver, mediaFilter);

        mediaOn = true;
    }

    // Set up GSM logging
    if (Settings.loggingGsm(this)) {
        gsmObserver = new GsmObserver(this);
        telManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
        telManager.listen(gsmObserver,
                PhoneStateListener.LISTEN_SERVICE_STATE | PhoneStateListener.LISTEN_CELL_LOCATION);
        gsmOn = true;
    }

    // Set up Airplane mode receiver
    if (Settings.loggingAir(this)) {
        IntentFilter airFilter = new IntentFilter(Intent.ACTION_AIRPLANE_MODE_CHANGED);

        airReceiver = new AirplaneReceiver(this);
        registerReceiver(airReceiver, airFilter);
        airOn = true;
    }

    // Set up Photos logging
    if (Settings.loggingPhotos(this)) {
        photoObserver = new PhotoObserver(this, this, handlering);
        photoOn = true;
    }

    // Set up SliceMultimediaFile
    if (Settings.uploadPhotos(this) || Settings.uploadRecords(this)) {
        mediaSlicer = new SliceMultimediaFile(this);
    }

    // Set up ConnectivityReceiver
    mConReceiver = new ConnectivityReceiver(this);
    registerReceiver(mConReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));

    // Ser up CallIntentReceiver
    //outCallReceiver = new CallIntentReceiver();
    //registerReceiver(outCallReceiver, new IntentFilter(KLService.OUTGOING_CALL));
}

From source file:com.aware.Aware.java

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

    awareContext = getApplicationContext();

    aware_preferences = getSharedPreferences("aware_core_prefs", MODE_PRIVATE);
    if (aware_preferences.getAll().isEmpty()) {
        SharedPreferences.Editor editor = aware_preferences.edit();
        editor.putInt(PREF_FREQUENCY_WATCHDOG, CONST_FREQUENCY_WATCHDOG);
        editor.putLong(PREF_LAST_SYNC, 0);
        editor.putLong(PREF_LAST_UPDATE, 0);
        editor.commit();/*from   w w w  .j a v a2  s  . com*/
    }

    IntentFilter filter = new IntentFilter();
    filter.addAction(Intent.ACTION_MEDIA_MOUNTED);
    filter.addAction(Intent.ACTION_MEDIA_UNMOUNTED);
    filter.addDataScheme("file");
    awareContext.registerReceiver(storage_BR, filter);

    filter = new IntentFilter();
    filter.addAction(Aware.ACTION_AWARE_CLEAR_DATA);
    filter.addAction(Aware.ACTION_AWARE_REFRESH);
    filter.addAction(Aware.ACTION_AWARE_SYNC_DATA);
    filter.addAction(DownloadManager.ACTION_DOWNLOAD_COMPLETE);
    awareContext.registerReceiver(aware_BR, filter);

    alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);

    awareStatusMonitor = new Intent(getApplicationContext(), Aware.class);
    repeatingIntent = PendingIntent.getService(getApplicationContext(), 0, awareStatusMonitor, 0);
    alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + 1000,
            aware_preferences.getInt(PREF_FREQUENCY_WATCHDOG, 300) * 1000, repeatingIntent);

    Intent synchronise = new Intent(Aware.ACTION_AWARE_SYNC_DATA);
    webserviceUploadIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, synchronise, 0);

    if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
        stopSelf();
    } else {
        SharedPreferences prefs = getSharedPreferences(getPackageName(), Context.MODE_PRIVATE);
        if (prefs.getAll().isEmpty()
                && Aware.getSetting(getApplicationContext(), Aware_Preferences.DEVICE_ID).length() == 0) {
            PreferenceManager.setDefaultValues(getApplicationContext(), getPackageName(), Context.MODE_PRIVATE,
                    R.xml.aware_preferences, true);
            prefs.edit().commit(); //commit changes
        } else {
            PreferenceManager.setDefaultValues(getApplicationContext(), getPackageName(), Context.MODE_PRIVATE,
                    R.xml.aware_preferences, false);
        }

        Map<String, ?> defaults = prefs.getAll();
        for (Map.Entry<String, ?> entry : defaults.entrySet()) {
            if (Aware.getSetting(getApplicationContext(), entry.getKey()).length() == 0) {
                Aware.setSetting(getApplicationContext(), entry.getKey(), entry.getValue());
            }
        }

        if (Aware.getSetting(getApplicationContext(), Aware_Preferences.DEVICE_ID).length() == 0) {
            UUID uuid = UUID.randomUUID();
            Aware.setSetting(getApplicationContext(), Aware_Preferences.DEVICE_ID, uuid.toString());
        }

        DEBUG = Aware.getSetting(awareContext, Aware_Preferences.DEBUG_FLAG).equals("true");
        TAG = Aware.getSetting(awareContext, Aware_Preferences.DEBUG_TAG).length() > 0
                ? Aware.getSetting(awareContext, Aware_Preferences.DEBUG_TAG)
                : TAG;

        get_device_info();

        if (Aware.DEBUG)
            Log.d(TAG, "AWARE framework is created!");

        //Fixed: only the client application does a ping to AWARE's server
        if (getPackageName().equals("com.aware")) {
            new AsyncPing().execute();
        }
    }
}