List of usage examples for android.content IntentFilter IntentFilter
public IntentFilter(Parcel source)
From source file:com.ubuntuone.android.files.service.UpDownService.java
private void registerUploadCancelReceiver() { LocalBroadcastManager bm = LocalBroadcastManager.getInstance(this); uploadCancelReceiver = new BroadcastReceiver() { @Override//from w w w . j av a 2 s . c o m public void onReceive(Context context, Intent intent) { if (uploadCancelReceiver != null) { uploadCancelTrigger.onCancel(); } Uri uri = intent.getData(); if (uri == null) { // Cancel all uploads. uri = Uploads.CONTENT_URI; } TransferUtils.dequeue(contentResolver, uri); } }; IntentFilter filter = new IntentFilter(ACTION_CANCEL_UPLOAD); bm.registerReceiver(uploadCancelReceiver, filter); }
From source file:RhodesService.java
@Override public void onCreate() { Logger.D(TAG, "onCreate"); sInstance = this; Context context = this; mNM = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); LocalFileProvider.revokeUriPermissions(this); Logger.I("Rhodes", "Loading..."); RhodesApplication.create();//from www . java2 s . c o m RhodesActivity ra = RhodesActivity.getInstance(); if (ra != null) { // Show splash screen only if we have active activity SplashScreen splashScreen = ra.getSplashScreen(); splashScreen.start(); // Increase WebView rendering priority WebView w = new WebView(context); WebSettings webSettings = w.getSettings(); webSettings.setRenderPriority(WebSettings.RenderPriority.HIGH); } initForegroundServiceApi(); // Register custom uri handlers here mUriHandlers.addElement(new ExternalHttpHandler(context)); mUriHandlers.addElement(new LocalFileHandler(context)); mUriHandlers.addElement(new MailUriHandler(context)); mUriHandlers.addElement(new TelUriHandler(context)); mUriHandlers.addElement(new SmsUriHandler(context)); mUriHandlers.addElement(new VideoUriHandler(context)); mConnectionChangeReceiver = new ConnectionChangeReceiver(); IntentFilter filter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION); registerReceiver(mConnectionChangeReceiver, filter); RhodesApplication.start(); if (BaseActivity.getActivitiesCount() > 0) handleAppActivation(); }
From source file:com.mdground.screen.activity.MainActivity.java
private void initService() { mClientRecive = new ClientReciver(); registerReceiver(mClientRecive, new IntentFilter("com.mdground.message")); // startService(new Intent("com.mdground.screen.service.DataService")); startService(new Intent(this, DataService.class)); xgReceiver = new XGPushReceiver(); registerReceiver(xgReceiver, new IntentFilter("com.mdground.screen.xgPush")); }
From source file:com.android.mms.ui.ConversationList.java
@Override protected void onStart() { super.onStart(); if (notDeleting) { MessagingNotification.cancelNotification(getApplicationContext(), SmsRejectedReceiver.SMS_REJECTED_NOTIFICATION_ID); DraftCache.getInstance().addOnDraftChangedListener(this); Intent it = getIntent();//from ww w . j a v a2 s. c o m Bundle bundle = it.getExtras(); if (bundle != null) { fromFolder = bundle.getBoolean("fromFolder", false); } if (fromFolder) { mNeedToMarkAsSeen = false; } else { mNeedToMarkAsSeen = true; } int dropNum = Conversation.cleanExpiredWapPush(this); if (0 < dropNum) { Toast.makeText(this, getResources().getString(R.string.dl_expired_wap_push, dropNum), Toast.LENGTH_LONG).show(); } startAsyncQuery(); // We used to refresh the DraftCache here, but // refreshing the DraftCache each time we go to the ConversationList seems overly // aggressive. We already update the DraftCache when leaving CMA in onStop() and // onNewIntent(), and when we delete threads or delete all in CMA or this activity. // I hope we don't have to do such a heavy operation each time we enter here. // we invalidate the contact cache here because we want to get updated presence // and any contact changes. We don't invalidate the cache by observing presence and contact // changes (since that's too untargeted), so as a tradeoff we do it here. // If we're in the middle of the app initialization where we're loading the conversation // threads, don't invalidate the cache because we're in the process of building it. // TODO: think of a better way to invalidate cache more surgically or based on actual // TODO: changes we care about if (!Conversation.loadingThreads()) { Contact.invalidateCache(); } // Listen for broadcast intents that indicate the SMS is ready IntentFilter filter = new IntentFilter(TelephonyIntents.ACTION_IS_SIM_SMS_READY); //===== fixed CR<NEWMS00127040> by luning at 11-10-07 begin ===== filter.addAction(TelephonyIntents.ACTION_IS_SIM_SMS_READY1); registerReceiver(mReceiver, filter); } }
From source file:cn.kangeqiu.kq.activity.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState != null) mContent = getSupportFragmentManager().getFragment(savedInstanceState, "mContent"); if (mContent == null) mContent = new FragmentMatch(R.color.red); // set the Above View setContentView(R.layout.content_frame); getSupportFragmentManager().beginTransaction().replace(R.id.content_frame, mContent).commit(); // set the Behind View setBehindContentView(R.layout.menu_frame); menuFragment = new MenuFragment(); personFragment = new MineActivity(); getSupportFragmentManager().beginTransaction().replace(R.id.menu_frame, menuFragment).commit(); // customize the SlidingMenu getSlidingMenu().setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN); context = this; if (savedInstanceState != null && savedInstanceState.getBoolean(Constant.ACCOUNT_REMOVED, false)) { // ??home???appcrash // fragment?? BaseApplication.getInstance().logout(null); finish();/*from w w w . j a v a 2 s . c o m*/ startActivity(new Intent(this, LoginActivity.class)); return; } else if (savedInstanceState != null && savedInstanceState.getBoolean("isConflict", false)) { // T??home???appcrash // fragment?? finish(); startActivity(new Intent(this, LoginActivity.class)); return; } setContentView(R.layout.activity_main); initView(); // MobclickAgent.setDebugMode( true ); // --?-- // MobclickAgent.updateOnlineConfig(this); if (getIntent().getBooleanExtra("conflict", false) && !isConflictDialogShow) { showConflictDialog(); } else if (getIntent().getBooleanExtra(Constant.ACCOUNT_REMOVED, false) && !isAccountRemovedDialogShow) { showAccountRemovedDialog(); } inviteMessgeDao = new InviteMessgeDao(this); userDao = new UserDao(this); // fragment??? // chatHistoryFragment = new ChatHistoryFragment(); // ?fragment chatHistoryFragment = new ChatAllHistoryFragment(); // contactListFragment = new ContactlistFragment(); // settingFragment = new SettingsFragment(); teamFragment = new FragmentMatch(); dataFragment = new FragmentData(); // nearbyFragment = new FragmentNearbyNew(); // finderFragment = new FragmentFinder(); // fragments = new Fragment[] { chatHistoryFragment, // nearbyFragment,finderFragment, teamFragment, personFragment }; fragments = new Fragment[] { teamFragment, chatHistoryFragment, dataFragment, personFragment }; // fragment // getSupportFragmentManager().beginTransaction() // .add(R.id.fragment_container, teamFragment).show(teamFragment) // .commit(); // getSupportFragmentManager().beginTransaction().add(R.id.fragment_container, // chatHistoryFragment) // .add(R.id.fragment_container, // contactListFragment).hide(contactListFragment).show(chatHistoryFragment).commit(); // ?BroadcastReceiver msgReceiver = new NewMessageBroadcastReceiver(); IntentFilter intentFilter = new IntentFilter(EMChatManager.getInstance().getNewMessageBroadcastAction()); intentFilter.setPriority(3); registerReceiver(msgReceiver, intentFilter); // ack?BroadcastReceiver IntentFilter ackMessageIntentFilter = new IntentFilter( EMChatManager.getInstance().getAckMessageBroadcastAction()); ackMessageIntentFilter.setPriority(3); registerReceiver(ackMessageReceiver, ackMessageIntentFilter); // ??BroadcastReceiver IntentFilter cmdMessageIntentFilter = new IntentFilter( EMChatManager.getInstance().getCmdMessageBroadcastAction()); cmdMessageIntentFilter.setPriority(3); registerReceiver(cmdMessageReceiver, cmdMessageIntentFilter); // ?BroadcastReceiver // IntentFilter offlineMessageIntentFilter = new // IntentFilter(EMChatManager.getInstance() // .getOfflineMessageBroadcastAction()); // registerReceiver(offlineMessageReceiver, offlineMessageIntentFilter); // setContactListener??? // EMContactManager.getInstance().setContactListener( // new MyContactListener()); // ??listener // EMChatManager.getInstance().addConnectionListener( // new MyConnectionListener()); // ?listener // EMGroupManager.getInstance().addGroupChangeListener( // new MyGroupChangeListener()); // sdkUI ??receiverlistener, ??broadcast EMChat.getInstance().setAppInited(); // ?? // initBaiduLocation(); }
From source file:com.p2p.misc.DeviceUtility.java
public float batteryLevel() { try {/* w w w .j ava 2s. c o m*/ BroadcastReceiver batteryReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { // context.unregisterReceiver(this); Intent batteryIntent = mactivity.registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED)); int rawlevel = batteryIntent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1); int scale = batteryIntent.getIntExtra(BatteryManager.EXTRA_SCALE, -1); if (level == -1 || scale == -1) { level = 50.0f; } if (rawlevel >= 0 && scale > 0) { level = ((float) level / (float) scale) * 100.0f; } set_BatteryLevel(level); // Constants.BATTERY_LEVEL=level; System.out.println("Battery Level Remaining: " + level + "%"); } }; IntentFilter filter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED); mactivity.registerReceiver(batteryReceiver, filter); } catch (Exception e) { e.printStackTrace(); } return level; }
From source file:com.ezac.gliderlogs.FlightOverviewActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); app_ini = true;/* w w w . j ava 2 s . com*/ // during start up of application we define our current date final Calendar c = Calendar.getInstance(); ToDay = Common.TwoDigits(c.get(Calendar.DAY_OF_MONTH)) + "-" + Common.TwoDigits(c.get(Calendar.MONTH) + 1) + "-" + Common.FourDigits(c.get(Calendar.YEAR)); Log.d(TAG, "Started, date = " + ToDay); if (!getSettings(context)) { SharedPreferences prefs = context.getSharedPreferences("Share", Context.MODE_PRIVATE); prefs.edit().clear(); SharedPreferences.Editor es = prefs.edit(); es.putString("com.ezac.gliderlogs.url", "host").apply(); es.putString("com.ezac.gliderlogs.pre", "45").apply(); es.putString("com.ezac.gliderlogs.scn", "300").apply(); es.putString("com.ezac.gliderlogs.key", "").apply(); es.putString("com.ezac.gliderlogs.sct", "").apply(); es.putString("com.ezac.gliderlogs.mst", "6319").apply(); es.putString("com.ezac.gliderlogs.mtr", "EHFS;EFWO").apply(); es.putString("com.ezac.gliderlogs.ntp", "").apply(); es.putString("com.ezac.gliderlogs.flg", "false;false;true;true;true;true;false;false;false;false") .apply(); es.putString("com.ezac.gliderlogs.lnd", "O - W").apply(); } String v[] = appFLG.split(";"); // check for loaded (glider / member) tables checktable(Boolean.parseBoolean(v[1])); // remove previous day(s) and/or already processed flights from table getTableFlightsCnt(ToDay, Boolean.parseBoolean(v[0]) ? 2 : 1); // check for unprocessed flights which are older than today if ((prev_cnt = getTableFlightsCnt(ToDay, 0)) != 0) { makeToast("Er zijn nog " + prev_cnt + " vluchten van een vorige vliegdag gevonden," + "\ndeze zullen, zodra er een WiFi verbinding is, alsnog" + "\nworden verzonden naar de server maar NIET zichtbaar zijn" + "\nin het overzicht voor deze vliegdag.", 1); } // normal execution may proceed setContentView(R.layout.start_list); this.getListView().setDividerHeight(2); // fillData(); registerForContextMenu(getListView()); // starts our handler activity after 1 minute scan.postDelayed(runnable, 60000); // load data for spinner into array list addItemSpinner_1(); addItemSpinner_2(); // left in place as to potential add next section in future disable screen lock /* PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE); wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE, "INFO"); wl.acquire(); this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON | WindowManager.LayoutParams.FLAG_FULLSCREEN | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON); Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD); */ // disable screen hide getListView().setKeepScreenOn(true); // setup event receiver for wifi IntentFilter filter = new IntentFilter(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION); this.registerReceiver(wifiStatusReceiver, filter); }
From source file:org.klnusbaum.udj.EventListFragment.java
private void registerEventListener() { getActivity().registerReceiver(eventJoinedReceiver, new IntentFilter(Constants.JOINED_EVENT_ACTION)); getActivity().registerReceiver(eventJoinedReceiver, new IntentFilter(Constants.EVENT_JOIN_FAILED_ACTION)); }
From source file:com.irccloud.android.activity.MainActivity.java
@SuppressLint("NewApi") @SuppressWarnings({ "deprecation", "unchecked" }) @Override//from w ww . j a va2 s . 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); }