List of usage examples for android.content IntentFilter addAction
public final void addAction(String action)
From source file:com.example.sensingapp.SensingApp.java
/** Called when the activity is first created. */ @Override/*from w w w. ja v a 2s . c o m*/ public void onCreate(Bundle savedInstanceState) { int i; Location location = null; super.onCreate(savedInstanceState); if (android.os.Build.VERSION.SDK_INT > 9) { StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); } try { Class.forName("android.os.AsyncTask"); } catch (ClassNotFoundException e) { e.printStackTrace(); } m_smSurScan = (SensorManager) getSystemService(SENSOR_SERVICE); PackageManager pm = getPackageManager(); m_riHome = pm.resolveActivity(new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME), 0); m_nBufferSize = AudioRecord.getMinBufferSize(m_nAudioSampleRate, AudioFormat.CHANNEL_IN_STEREO, AudioFormat.ENCODING_PCM_16BIT); m_tmCellular = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); checkSensorAvailability(); //Get Existing Project Name and Existing User Name preconfigSetting(); /* When the power button is pressed and the screen goes off, the sensors will stop work by default, * Here keep the CPU on to keep sensor alive and also use SCREEN_OFF notification to re-enable GPS/WiFi */ PowerManager pwrManager = (PowerManager) getSystemService(Context.POWER_SERVICE); m_wakeLock = pwrManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG); IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON); filter.addAction(Intent.ACTION_SCREEN_OFF); registerReceiver(m_ScreenOffReceiver, filter); show_screen1(); }
From source file:com.dwdesign.tweetings.service.TweetingsService.java
@Override public void onCreate() { super.onCreate(); mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); mAlarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE); mAsyncTaskManager = ((TweetingsApplication) getApplication()).getAsyncTaskManager(); mPreferences = getSharedPreferences(SHARED_PREFERENCES_NAME, MODE_PRIVATE); mResolver = getContentResolver();/*from w w w . ja v a 2 s . c o m*/ mPendingRefreshHomeTimelineIntent = PendingIntent.getBroadcast(this, 0, new Intent(BROADCAST_REFRESH_HOME_TIMELINE), 0); mPendingRefreshMentionsIntent = PendingIntent.getBroadcast(this, 0, new Intent(BROADCAST_REFRESH_MENTIONS), 0); mPendingRefreshDirectMessagesIntent = PendingIntent.getBroadcast(this, 0, new Intent(BROADCAST_REFRESH_DIRECT_MESSAGES), 0); final IntentFilter filter = new IntentFilter(BROADCAST_REFRESHSTATE_CHANGED); filter.addAction(BROADCAST_NOTIFICATION_CLEARED); filter.addAction(BROADCAST_REFRESH_HOME_TIMELINE); filter.addAction(BROADCAST_REFRESH_MENTIONS); filter.addAction(BROADCAST_REFRESH_DIRECT_MESSAGES); filter.addAction(Intent.ACTION_BATTERY_LOW); filter.addAction(Intent.ACTION_BATTERY_OKAY); registerReceiver(mStateReceiver, filter); startAutoRefresh(); }
From source file:com.android.launcher3.Launcher.java
@Override public void onAttachedToWindow() { super.onAttachedToWindow(); // Listen for broadcasts related to user-presence final IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_SCREEN_OFF); filter.addAction(Intent.ACTION_USER_PRESENT); registerReceiver(mReceiver, filter); FirstFrameAnimatorHelper.initializeDrawListener(getWindow().getDecorView()); mAttached = true;/* w w w. j a va2 s . c o m*/ mVisible = true; if (mLauncherCallbacks != null) { mLauncherCallbacks.onAttachedToWindow(); } }
From source file:com.klinker.android.launcher.launcher3.Launcher.java
@Override public void onAttachedToWindow() { super.onAttachedToWindow(); // Listen for broadcasts related to user-presence final IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_SCREEN_OFF); filter.addAction(Intent.ACTION_USER_PRESENT); // For handling managed profiles if (ENABLE_DEBUG_INTENTS) { filter.addAction(DebugIntents.DELETE_DATABASE); filter.addAction(DebugIntents.MIGRATE_DATABASE); }/*from w w w. j av a 2 s.c o m*/ registerReceiver(mReceiver, filter); FirstFrameAnimatorHelper.initializeDrawListener(getWindow().getDecorView()); setupTransparentSystemBarsForLmp(); mAttached = true; mVisible = true; }
From source file:com.android.soma.Launcher.java
@Override public void onAttachedToWindow() { super.onAttachedToWindow(); // Listen for broadcasts related to user-presence final IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_SCREEN_OFF); filter.addAction(Intent.ACTION_USER_PRESENT); registerReceiver(mReceiver, filter); FirstFrameAnimatorHelper.initializeDrawListener(getWindow().getDecorView()); mAttached = true;/*from w w w.ja va2 s. c o m*/ mVisible = true; }
From source file:com.irccloud.android.activity.MainActivity.java
@SuppressLint("NewApi") @SuppressWarnings({ "deprecation", "unchecked" }) @Override// w w w. j a v a2s. c o m public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); suggestionsTimer = new Timer("suggestions-timer"); countdownTimer = new Timer("messsage-countdown-timer"); IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON); filter.addAction(Intent.ACTION_SCREEN_OFF); registerReceiver(screenReceiver, filter); if (Build.VERSION.SDK_INT >= 21) { Bitmap cloud = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher); if (cloud != null) { setTaskDescription(new ActivityManager.TaskDescription(getResources().getString(R.string.app_name), cloud, 0xFFF2F7FC)); cloud.recycle(); } } setContentView(R.layout.activity_message); try { setSupportActionBar((Toolbar) findViewById(R.id.toolbar)); } catch (Throwable t) { } suggestionsAdapter = new SuggestionsAdapter(); progressBar = (ProgressBar) findViewById(R.id.progress); errorMsg = (TextView) findViewById(R.id.errorMsg); buffersListView = findViewById(R.id.BuffersList); messageContainer = (LinearLayout) findViewById(R.id.messageContainer); drawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout); redColor = getResources().getColor(R.color.highlight_red); blueColor = getResources().getColor(R.color.dark_blue); messageTxt = (ActionEditText) findViewById(R.id.messageTxt); messageTxt.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (sendBtn.isEnabled() && NetworkConnection.getInstance().getState() == NetworkConnection.STATE_CONNECTED && event.getAction() == KeyEvent.ACTION_DOWN && keyCode == KeyEvent.KEYCODE_ENTER && messageTxt.getText() != null && messageTxt.getText().length() > 0) { sendBtn.setEnabled(false); new SendTask().execute((Void) null); } else if (keyCode == KeyEvent.KEYCODE_TAB) { if (event.getAction() == KeyEvent.ACTION_DOWN) nextSuggestion(); return true; } return false; } }); messageTxt.setOnFocusChangeListener(new OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (drawerLayout != null && v == messageTxt && hasFocus) { drawerLayout.closeDrawers(); update_suggestions(false); } else if (!hasFocus) { runOnUiThread(new Runnable() { @Override public void run() { suggestionsContainer.setVisibility(View.INVISIBLE); } }); } } }); messageTxt.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (drawerLayout != null) { drawerLayout.closeDrawers(); } } }); messageTxt.setOnEditorActionListener(new OnEditorActionListener() { public boolean onEditorAction(TextView view, int actionId, KeyEvent event) { if (sendBtn.isEnabled() && NetworkConnection.getInstance().getState() == NetworkConnection.STATE_CONNECTED && actionId == EditorInfo.IME_ACTION_SEND && messageTxt.getText() != null && messageTxt.getText().length() > 0) { sendBtn.setEnabled(false); new SendTask().execute((Void) null); } return true; } }); textWatcher = new TextWatcher() { public void afterTextChanged(Editable s) { Object[] spans = s.getSpans(0, s.length(), Object.class); for (Object o : spans) { if (((s.getSpanFlags(o) & Spanned.SPAN_COMPOSING) != Spanned.SPAN_COMPOSING) && (o.getClass() == StyleSpan.class || o.getClass() == ForegroundColorSpan.class || o.getClass() == BackgroundColorSpan.class || o.getClass() == UnderlineSpan.class || o.getClass() == URLSpan.class)) { s.removeSpan(o); } } if (s.length() > 0 && NetworkConnection.getInstance().getState() == NetworkConnection.STATE_CONNECTED) { sendBtn.setEnabled(true); if (Build.VERSION.SDK_INT >= 11) sendBtn.setAlpha(1); } else { sendBtn.setEnabled(false); if (Build.VERSION.SDK_INT >= 11) sendBtn.setAlpha(0.5f); } String text = s.toString(); if (text.endsWith("\t")) { //Workaround for Swype text = text.substring(0, text.length() - 1); messageTxt.setText(text); nextSuggestion(); } else if (suggestionsContainer != null && suggestionsContainer.getVisibility() == View.VISIBLE) { runOnUiThread(new Runnable() { @Override public void run() { update_suggestions(false); } }); } else { if (suggestionsTimer != null) { if (suggestionsTimerTask != null) suggestionsTimerTask.cancel(); suggestionsTimerTask = new TimerTask() { @Override public void run() { Thread.currentThread().setPriority(Thread.MIN_PRIORITY); update_suggestions(false); } }; suggestionsTimer.schedule(suggestionsTimerTask, 250); } } } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void onTextChanged(CharSequence s, int start, int before, int count) { } }; messageTxt.addTextChangedListener(textWatcher); sendBtn = findViewById(R.id.sendBtn); sendBtn.setFocusable(false); sendBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (NetworkConnection.getInstance().getState() == NetworkConnection.STATE_CONNECTED) new SendTask().execute((Void) null); } }); photoBtn = findViewById(R.id.photoBtn); if (photoBtn != null) { photoBtn.setFocusable(false); photoBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { insertPhoto(); } }); } userListView = findViewById(R.id.usersListFragment); View v = getLayoutInflater().inflate(R.layout.actionbar_messageview, null); v.findViewById(R.id.actionTitleArea).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { show_topic_popup(); } }); if (drawerLayout != null) { if (findViewById(R.id.usersListFragment2) == null) { upDrawable = new DrawerArrowDrawable(this); greyColor = upDrawable.getColor(); ((Toolbar) findViewById(R.id.toolbar)).setNavigationIcon(upDrawable); ((Toolbar) findViewById(R.id.toolbar)).setNavigationContentDescription("Show navigation drawer"); drawerLayout.setDrawerListener(mDrawerListener); if (refreshUpIndicatorTask != null) refreshUpIndicatorTask.cancel(true); refreshUpIndicatorTask = new RefreshUpIndicatorTask(); refreshUpIndicatorTask.execute((Void) null); } } messageTxt.setDrawerLayout(drawerLayout); title = (TextView) v.findViewById(R.id.title); subtitle = (TextView) v.findViewById(R.id.subtitle); key = (ImageView) v.findViewById(R.id.key); getSupportActionBar().setCustomView(v); getSupportActionBar().setDisplayShowCustomEnabled(true); getSupportActionBar().setDisplayShowTitleEnabled(false); if (savedInstanceState != null && savedInstanceState.containsKey("cid")) { server = ServersDataSource.getInstance().getServer(savedInstanceState.getInt("cid")); buffer = BuffersDataSource.getInstance().getBuffer(savedInstanceState.getInt("bid")); backStack = (ArrayList<Integer>) savedInstanceState.getSerializable("backStack"); } if (savedInstanceState != null && savedInstanceState.containsKey("imagecaptureuri")) imageCaptureURI = Uri.parse(savedInstanceState.getString("imagecaptureuri")); else imageCaptureURI = null; ConfigInstance config = (ConfigInstance) getLastCustomNonConfigurationInstance(); if (config != null) { imgurTask = config.imgurUploadTask; fileUploadTask = config.fileUploadTask; } drawerLayout.setScrimColor(0); drawerLayout.closeDrawers(); getSupportActionBar().setElevation(0); }
From source file:com.cognizant.trumobi.PersonaLauncher.java
private void registerIntentReceivers() { boolean useNotifReceiver = PersonaAlmostNexusSettingsHelper.getNotifReceiver(this); if (useNotifReceiver && mCounterReceiver == null) { mCounterReceiver = new PersonaCounterReceiver(this); mCounterReceiver.setCounterListener(new PersonaCounterReceiver.OnCounterChangedListener() { public void onTrigger(String pname, int counter, int color) { PersonaLog.d("personalauncher", "updateCountersForPackage called from registerIntentReceivers"); //updateCountersForPackage(pname, counter, color, 0); Bundle b = new Bundle(); b.putString("package", "com.cognizant.trumobi"); b.putInt("counter", counter); b.putInt("color", R.color.PR_TEXTBOX_FOCUSED_COLOR); b.putInt("updateCountFor", 0); Message m = new Message(); m.setData(b);//from ww w . j a v a2s . com UiHandler.sendMessage(m); } }); registerReceiver(mCounterReceiver, mCounterReceiver.getFilter()); } IntentFilter filter = new IntentFilter(Intent.ACTION_PACKAGE_ADDED); filter.addAction(Intent.ACTION_PACKAGE_REMOVED); filter.addAction(Intent.ACTION_PACKAGE_CHANGED); filter.addDataScheme("package"); registerReceiver(mApplicationsReceiver, filter); filter = new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS); registerReceiver(mCloseSystemDialogsReceiver, filter); filter = new IntentFilter(); filter.addAction(Intent.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE); filter.addAction(Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE); registerReceiver(mApplicationsReceiver, filter); }