List of usage examples for android.content IntentFilter addAction
public final void addAction(String action)
From source file:com.allwinner.theatreplayer.launcher.activity.LaunchActivity.java
private void registerHomeKeyEventReceiver() { IntentFilter HomeKeyfilter = new IntentFilter(); HomeKeyfilter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS); registerReceiver(mHomeKeyEventReceiver, HomeKeyfilter); }
From source file:com.allwinner.theatreplayer.launcher.activity.LaunchActivity.java
private void registerAppBroadcastReceiver() { IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(UpdateService.APKDOWNSUC); intentFilter.addAction(UpdateService.APKONCHECKED); intentFilter.addAction("android.net.conn.CONNECTIVITY_CHANGE"); registerReceiver(mAppBroadcastReceiver, intentFilter); }
From source file:cw.kop.autobackground.sources.SourceListFragment.java
@Override public void onResume() { super.onResume(); sourceList.setOnItemClickListener(this); new ImageCountTask().execute(); IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(FileHandler.DOWNLOAD_TERMINATED); intentFilter.addAction(ADD_ENTRY);//from www . ja va 2s. co m intentFilter.addAction(SET_ENTRY); LocalBroadcastManager.getInstance(appContext).registerReceiver(sourceListReceiver, intentFilter); if (isServiceRunning(LiveWallpaperService.class.getName())) { setButton.setVisibility(View.GONE); } else { setButton.setVisibility(View.VISIBLE); } }
From source file:org.linphone.LinphoneService.java
public void initFromConf() throws LinphoneConfigException, LinphoneException { // traces//from w ww.j a v a2 s .c om boolean lIsDebug = mPref.getBoolean(getString(R.string.pref_debug_key), false); LinphoneCoreFactory.instance().setDebugMode(lIsDebug); try { // Configure audio codecs enableDisableAudioCodec("speex", 32000, R.string.pref_codec_speex32_key); enableDisableAudioCodec("speex", 16000, R.string.pref_codec_speex16_key); enableDisableAudioCodec("speex", 8000, R.string.pref_codec_speex8_key); enableDisableAudioCodec("iLBC", 8000, R.string.pref_codec_ilbc_key); enableDisableAudioCodec("GSM", 8000, R.string.pref_codec_gsm_key); enableDisableAudioCodec("PCMU", 8000, R.string.pref_codec_pcmu_key); enableDisableAudioCodec("PCMA", 8000, R.string.pref_codec_pcma_key); // Configure video codecs for (PayloadType videoCodec : mLinphoneCore.listVideoCodecs()) { enableDisableVideoCodecs(videoCodec); } if (!mPref.getString(getString(R.string.pref_handle_outcall_key), OutgoingCallReceiver.key_on_demand) .equalsIgnoreCase(OutgoingCallReceiver.key_off)) { IntentFilter lFilter = new IntentFilter(Intent.ACTION_SCREEN_ON); lFilter.setPriority(0); lFilter.addAction(Intent.ACTION_NEW_OUTGOING_CALL); if (mOutgoingCallReceiver == null) { mOutgoingCallReceiver = new OutgoingCallReceiver(); } registerReceiver(mOutgoingCallReceiver, lFilter); } else if (mOutgoingCallReceiver != null) { unregisterReceiver(mOutgoingCallReceiver); mOutgoingCallReceiver = null; } mLinphoneCore.enableEchoCancellation( mPref.getBoolean(getString(R.string.pref_echo_cancellation_key), false)); } catch (LinphoneCoreException e) { throw new LinphoneConfigException(getString(R.string.wrong_settings), e); } boolean isVideoEnabled = mPref.getBoolean(getString(R.string.pref_video_enable_key), false); mLinphoneCore.enableVideo(isVideoEnabled, isVideoEnabled); // 1 read proxy config from preferences String lUserName = mPref.getString(getString(R.string.pref_username_key), null); lUserName = username; if (lUserName == null || lUserName.length() == 0) { throw new LinphoneConfigException(getString(R.string.wrong_username)); } String lPasswd = mPref.getString(getString(R.string.pref_passwd_key), null); lPasswd = password; if (lPasswd == null || lPasswd.length() == 0) { throw new LinphoneConfigException(getString(R.string.wrong_passwd)); } String lDomain = mPref.getString(getString(R.string.pref_domain_key), null); lDomain = domain; if (lDomain == null || lDomain.length() == 0) { throw new LinphoneConfigException(getString(R.string.wrong_domain)); } String lStun = mPref.getString(getString(R.string.pref_stun_server_key), null); // stun server mLinphoneCore.setStunServer(lStun); mLinphoneCore.setFirewallPolicy( (lStun != null && lStun.length() > 0) ? FirewallPolicy.UseStun : FirewallPolicy.NoFirewall); // auth mLinphoneCore.clearAuthInfos(); LinphoneAuthInfo lAuthInfo = LinphoneCoreFactory.instance().createAuthInfo(lUserName, lPasswd, null); mLinphoneCore.addAuthInfo(lAuthInfo); // proxy mLinphoneCore.clearProxyConfigs(); String lProxy = mPref.getString(getString(R.string.pref_proxy_key), null); if (lProxy == null || lProxy.length() == 0) { lProxy = "sip:" + lDomain; } if (!lProxy.startsWith("sip:")) { lProxy = "sip:" + lProxy; } // get Default proxy if any LinphoneProxyConfig lDefaultProxyConfig = mLinphoneCore.getDefaultProxyConfig(); String lIdentity = "sip:" + lUserName + "@" + lDomain; try { if (lDefaultProxyConfig == null) { lDefaultProxyConfig = LinphoneCoreFactory.instance().createProxyConfig(lIdentity, lProxy, null, true); mLinphoneCore.addProxyConfig(lDefaultProxyConfig); mLinphoneCore.setDefaultProxyConfig(lDefaultProxyConfig); } else { lDefaultProxyConfig.edit(); lDefaultProxyConfig.setIdentity(lIdentity); lDefaultProxyConfig.setProxy(lProxy); lDefaultProxyConfig.enableRegister(true); lDefaultProxyConfig.done(); } lDefaultProxyConfig = mLinphoneCore.getDefaultProxyConfig(); if (lDefaultProxyConfig != null) { // prefix String lPrefix = mPref.getString(getString(R.string.pref_prefix_key), null); if (lPrefix != null) { lDefaultProxyConfig.setDialPrefix(lPrefix); } // escape + lDefaultProxyConfig .setDialEscapePlus(mPref.getBoolean(getString(R.string.pref_escape_plus_key), false)); // outbound proxy if (mPref.getBoolean(getString(R.string.pref_enable_outbound_proxy_key), false)) { lDefaultProxyConfig.setRoute(lProxy); } else { lDefaultProxyConfig.setRoute(null); } } // init network state ConnectivityManager lConnectivityManager = (ConnectivityManager) getSystemService( Context.CONNECTIVITY_SERVICE); NetworkInfo lInfo = lConnectivityManager.getActiveNetworkInfo(); mLinphoneCore.setNetworkReachable(lInfo != null ? lConnectivityManager.getActiveNetworkInfo().getState() == NetworkInfo.State.CONNECTED : false); } catch (LinphoneCoreException e) { throw new LinphoneConfigException(getString(R.string.wrong_settings), e); } }
From source file:jp.ksksue.app.terminal.AndroidUSBSerialMonitorLite.java
/** Called when the activity is first created. */ @Override//ww w . j av a 2 s .c om public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); /* FIXME : How to check that there is a title bar menu or not. // Should not set a Window.FEATURE_NO_TITLE on Honeycomb because a user cannot see menu button. if(isICSorHigher) { if(!getWindow().hasFeature(Window.FEATURE_ACTION_BAR)) { requestWindowFeature(Window.FEATURE_NO_TITLE); } } */ setContentView(R.layout.main); mSvText = (ScrollView) findViewById(R.id.svText); mTvSerial = (TextView) findViewById(R.id.tvSerial); btWrite = (Button) findViewById(R.id.btWrite); btWrite.setEnabled(false); etWrite = (EditText) findViewById(R.id.etWrite); etWrite.setEnabled(false); etWrite.setHint("CR : \\r, LF : \\n, bin : \\u0000"); if (SHOW_DEBUG) { Log.d(TAG, "New FTDriver"); } // get service mSerial = new Physicaloid(this); if (SHOW_DEBUG) { Log.d(TAG, "New instance : " + mSerial); } // listen for new devices IntentFilter filter = new IntentFilter(); filter.addAction(UsbManager.ACTION_USB_DEVICE_ATTACHED); filter.addAction(UsbManager.ACTION_USB_DEVICE_DETACHED); registerReceiver(mUsbReceiver, filter); if (SHOW_DEBUG) { Log.d(TAG, "FTDriver beginning"); } openUsbSerial(); etWrite.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_ENTER) { writeDataToSerial(); return true; } return false; } }); // --------------------------------------------------------------------------------------- // Write Button // --------------------------------------------------------------------------------------- if (!USE_WRITE_BUTTON_FOR_DEBUG) { btWrite.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { writeDataToSerial(); } }); } else { // Write test button for debug btWrite.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String strWrite = ""; for (int i = 0; i < 3000; ++i) { strWrite = strWrite + " " + Integer.toString(i); } if (SHOW_DEBUG) { Log.d(TAG, "FTDriver Write(" + strWrite.length() + ") : " + strWrite); } mSerial.write(strWrite.getBytes(), strWrite.length()); } }); } // end of if(SHOW_WRITE_TEST_BUTTON) btnLoad = (Button) findViewById(R.id.btnLoad); btnLoad.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { SimpleFileDialog simpleFileDialog = new SimpleFileDialog(AndroidUSBSerialMonitorLite.this, "FileOpen", new SimpleFileDialog.SimpleFileDialogListener() { @Override public void onChosenDir(String chosenDir) { File file = null; FileInputStream fileInputStream = null; byte[] data; try { file = new File(chosenDir); if (file.isDirectory()) { throw new IOException("not file"); } fileInputStream = new FileInputStream(file); data = new byte[(int) file.length()]; fileInputStream.read(data); String dataText = new String(data, "UTF-8"); parseJSON(dataText); } catch (IOException e) { Toast.makeText(AndroidUSBSerialMonitorLite.this, e.getMessage(), Toast.LENGTH_SHORT).show(); } finally { if (fileInputStream != null) { try { fileInputStream.close(); } catch (IOException e) { e.printStackTrace(); } } } } }); simpleFileDialog.chooseFile_or_Dir(); } }); btnPlay = (Button) findViewById(R.id.btnPlay); btnPlay.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { startIrBeaconPulse(); } }); btnStop = (Button) findViewById(R.id.btnStop); btnStop.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { stopIrBeaconPulse(); } }); btnPlay.setEnabled(false); btnStop.setEnabled(false); }
From source file:com.andreadec.musicplayer.MainActivity.java
@Override public void onResume() { super.onResume(); if (musicService != null) startRoutine();// w w w . j av a2 s. c o m // Enable the broadcast receiver IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction("com.andreadec.musicplayer.newsong"); intentFilter.addAction("com.andreadec.musicplayer.playpausechanged"); intentFilter.addAction("com.andreadec.musicplayer.podcastdownloadcompleted"); intentFilter.addAction("com.andreadec.musicplayer.quitactivity"); broadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if (intent.getAction().equals("com.andreadec.musicplayer.newsong")) { updatePlayingItem(); } else if (intent.getAction().equals("com.andreadec.musicplayer.playpausechanged")) { updatePlayPauseButton(); } else if (intent.getAction().equals("com.andreadec.musicplayer.podcastdownloadcompleted")) { if (currentPage == PAGE_PODCASTS) { PodcastsFragment podcastsFragment = (PodcastsFragment) currentFragment; podcastsFragment.updateListView(true); } } else if (intent.getAction().equals("com.andreadec.musicplayer.quitactivity")) { finish(); // I don't call quitActivity() because the service closes himself after sending this broadcast } } }; registerReceiver(broadcastReceiver, intentFilter); updatePlayPauseButton(); }
From source file:eu.fistar.sdcs.pa.PAManagerService.java
/** * Discover all the DA available on the system *///from w ww . j av a 2 s . c o m private void discoverDAs() { Log.i(PAAndroidConstants.PA_LOGTAG, "Starting Device Adapter discovery"); // Create the Intent to broadcast Intent intent = new Intent(DA_DISCOVERY.REQUEST_ACTION); intent.putExtra(DA_DISCOVERY.BUNDLE_REPACT, DA_DISCOVERY.REPLY_ACTION); // Create the Intent Filter to receive broadcast replies IntentFilter filter = new IntentFilter(); filter.addAction(DA_DISCOVERY.REPLY_ACTION); // Register the Broadcast Receiver for replies and set it to run in another thread HandlerThread ht = new HandlerThread("ht"); ht.start(); registerReceiver(broadcastDiscoveryDA, filter, null, new Handler(ht.getLooper())); // Send in broadcast the Intent for discovery sendBroadcast(intent); // Create a new Thread object to stop the discovery and also use it as a lock ScanningStopAndLock r = new ScanningStopAndLock(); // Set the timeout for receiving replies r.start(); // Wait for the scanning to be done before returning synchronized (r) { while (!r.isDiscoveryDone()) { try { r.wait(); } catch (InterruptedException e) { // Just wait until scanning is done } } } }
From source file:com.givon.anhao.activity.AnhaoMainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mWL = getWindow().getAttributes();//from w ww. j av a 2 s . co m initView(); mTitleBar = (AppTitleBar) findViewById(R.id.titlebar); mTitleBar.setBackOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mSlideMenu.isOpened()) { mSlideMenu.closeMenu(); } else { mSlideMenu.openMenu(); } } }); mTitleBar.setMoreIcon(R.drawable.back_icon); mTitleBar.setMoreOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (isGroup) { isGroup = false; FragmentTransaction trx = getSupportFragmentManager().beginTransaction(); trx.hide(fragments[0]); if (!fragments[1].isAdded()) { trx.add(R.id.fragment_container, fragments[1]); } trx.show(fragments[1]).commit(); } else { isGroup = true; FragmentTransaction trx = getSupportFragmentManager().beginTransaction(); trx.hide(fragments[1]); if (!fragments[0].isAdded()) { trx.add(R.id.fragment_container, fragments[0]); } trx.show(fragments[0]).commit(); } } }); // SDK ? IntentFilter iFilter = new IntentFilter(); iFilter.addAction(SDKInitializer.SDK_BROADTCAST_ACTION_STRING_PERMISSION_CHECK_ERROR); iFilter.addAction(SDKInitializer.SDK_BROADCAST_ACTION_STRING_NETWORK_ERROR); mReceiver = new SDKReceiver(); registerReceiver(mReceiver, iFilter); inviteMessgeDao = new InviteMessgeDao(this); userDao = new UserDaoOld(this); chatHistoryFragment = new ChatHistoryFragment(); // contactListFragment = new ContactlistFragment(); groupFragment = new GroupFragment(); fragments = new Fragment[] { groupFragment, chatHistoryFragment }; // fragment getSupportFragmentManager().beginTransaction().add(R.id.fragment_container, groupFragment) .add(R.id.fragment_container, chatHistoryFragment).hide(chatHistoryFragment).show(groupFragment) .commit(); mSlideMenu.clearIgnoredViewList(); // ?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); // setContactListener??? EMContactManager.getInstance().setContactListener(new MyContactListener()); // ??listener EMChatManager.getInstance().addConnectionListener(new MyConnectionListener()); // ?listener EMGroupManager.getInstance().addGroupChangeListener(new MyGroupChangeListener()); // sdkUI ??receiverlistener, ??broadcast EMChat.getInstance().setAppInited(); }
From source file:com.dwdesign.tweetings.activity.HomeActivity.java
@Override public void onStart() { super.onStart(); setSupportProgressBarIndeterminateVisibility(mProgressBarIndeterminateVisible); final IntentFilter filter = new IntentFilter(BROADCAST_REFRESHSTATE_CHANGED); filter.addAction(WifiManager.SUPPLICANT_CONNECTION_CHANGE_ACTION); filter.addAction(BROADCAST_NETWORK_STATE_CHANGED); filter.addAction(BROADCAST_TABS_NEW_TWEETS); filter.addAction(BROADCAST_TABS_READ_TWEETS); filter.addAction(BROADCAST_ACCOUNT_LIST_DATABASE_UPDATED); registerReceiver(mStateReceiver, filter); final boolean show_home_tab = mPreferences.getBoolean(PREFERENCE_KEY_SHOW_HOME_TAB, true); final boolean show_mentions_tab = mPreferences.getBoolean(PREFERENCE_KEY_SHOW_MENTIONS_TAB, true); final boolean show_messages_tab = mPreferences.getBoolean(PREFERENCE_KEY_SHOW_MESSAGES_TAB, true); final boolean show_accounts_tab = mPreferences.getBoolean(PREFERENCE_KEY_SHOW_ACCOUNTS_TAB, true); final boolean show_search_tab = mPreferences.getBoolean(PREFERENCE_KEY_SHOW_SEARCH_TAB, true); final boolean show_lists_tab = mPreferences.getBoolean(PREFERENCE_KEY_SHOW_LISTS_TAB, true); final List<TabSpec> tabs = getTabs(this); if (isTabsChanged(tabs) || show_home_tab != mShowHomeTab || show_mentions_tab != mShowMentionsTab || show_messages_tab != mShowMessagesTab || show_accounts_tab != mShowAccountsTab || show_search_tab != mShowSearchTab || show_lists_tab != mShowListsTab) { restart();// w ww . ja va 2 s . c o m } if (mPreferences.getBoolean(PREFERENCE_KEY_STREAMING_ENABLED, false) == true) { if (mService != null) { try { Twitter twitter = com.dwdesign.tweetings.util.Utils .getDefaultTwitterInstance(getApplicationContext(), true); twitterStream = new TwitterStreamFactory().getInstance(twitter.getAuthorization()); twitterStream.addListener(listener); } catch (final Exception e) { e.printStackTrace(); } } } }
From source file:com.htc.dotdesign.ToolBoxService.java
@Override public void onCreate() { Log.d(DotDesignConstants.LOG_TAG, LOG_PREFIX + "onCreate"); super.onCreate(); Resources res = getResources(); mWindowManager = (WindowManager) getSystemService(WINDOW_SERVICE); mLocalBroadcastManager = LocalBroadcastManager.getInstance(this); if (mLocalBroadcastManager != null) { IntentFilter filter = new IntentFilter(); filter.addAction(SHOW_HIDE_TOOL_BAR); filter.addAction(USER_START_DRAWING); mLocalBroadcastManager.registerReceiver(mToolBarReceiver, filter); }/*from w w w . j ava 2s .co m*/ // Get full window size Display display = mWindowManager.getDefaultDisplay(); Point size = new Point(); display.getRealSize(size); mScreenWidth = size.x; mScreenHeight = size.y; // Get arrow width BitmapFactory.Options bitmapOptions = new BitmapFactory.Options(); bitmapOptions.inJustDecodeBounds = true; BitmapFactory.decodeResource(res, R.drawable.dot_design_popupmenu_arrow, bitmapOptions); mArrowWidth = bitmapOptions.outWidth; // Initialize LayoutParams mDragButtonParams = new WindowManager.LayoutParams(res.getDimensionPixelSize(R.dimen.drag_button_width), res.getDimensionPixelSize(R.dimen.drag_button_height), WindowManager.LayoutParams.TYPE_PHONE, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, PixelFormat.TRANSLUCENT); mDragButtonParams.gravity = Gravity.TOP | Gravity.START; mDragButtonParams.x = 0; mDragButtonParams.y = mScreenHeight / 2; mToolBarParams = new WindowManager.LayoutParams(res.getDimensionPixelSize(R.dimen.tool_bar_width), res.getDimensionPixelSize(R.dimen.tool_bar_height), WindowManager.LayoutParams.TYPE_PHONE, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, PixelFormat.TRANSLUCENT); mToolBarParams.alpha = 0.9f; mToolBarParams.gravity = Gravity.TOP | Gravity.START; mToolBarParams.x = 0; mToolBarParams.y = mDragButtonParams.y; // Initialize drag button width and height //mDragButtonWidth = res.getDimensionPixelSize(R.dimen.drag_button_width); mDragButtonHeight = res.getDimensionPixelSize(R.dimen.drag_button_height); mDragBtnColorIcon = (GradientDrawable) res.getDrawable(R.drawable.round_button); mDragBtnEraserIcon = res.getDrawable(R.drawable.dot_design_circle_shape_dark); // Inflate layout LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); mDragButton = inflater.inflate(R.layout.drag_button, null); mToolBarParent = inflater.inflate(R.layout.tool_bar, null); mPalette = inflater.inflate(R.layout.palette, null); mEraser = inflater.inflate(R.layout.eraser, null); mMenu = inflater.inflate(R.layout.menu, null); initToolBar(); initMenu(); initAnimation(); initBrushColor(); initDragButton(); mWindowManager.addView(mToolBarParent, mToolBarParams); mWindowManager.addView(mDragButton, mDragButtonParams); mToolBarParent.setVisibility(View.INVISIBLE); }