List of usage examples for android.content IntentFilter IntentFilter
public IntentFilter(Parcel source)
From source file:com.compal.telephonytest.TelephonyTest.java
public void prepareSMS() { IntentFilter sendIntentFilter = new IntentFilter(SMS_SEND_ACTION); IntentFilter deliveryIntentFilter = new IntentFilter(SMS_DELIVERY_ACTION); IntentFilter dataSmsReceivedIntentFilter = new IntentFilter(DATA_SMS_RECEIVED_ACTION); mSendIntent = new Intent(SMS_SEND_ACTION); mDeliveryIntent = new Intent(SMS_DELIVERY_ACTION); dataSmsReceivedIntentFilter.addDataScheme("sms"); dataSmsReceivedIntentFilter.addDataAuthority("localhost", port.toString()); context.registerReceiver(SmsBroadcastReceiver, sendIntentFilter); context.registerReceiver(SmsBroadcastReceiver, deliveryIntentFilter); context.registerReceiver(SmsBroadcastReceiver, dataSmsReceivedIntentFilter); mText = mText + "_" + Long.toString(System.currentTimeMillis()); PendingIntent mSentIntent = PendingIntent.getBroadcast(getInstrumentation().getTargetContext(), 0, mSendIntent, PendingIntent.FLAG_ONE_SHOT); PendingIntent mDeliveredIntent = PendingIntent.getBroadcast(getInstrumentation().getTargetContext(), 0, mDeliveryIntent, PendingIntent.FLAG_ONE_SHOT); byte[] data = mText.getBytes(); mSmsManager.sendDataMessage(mPhoneNumber, null, port, data, mSentIntent, mDeliveredIntent); }
From source file:org.linphone.LinphoneService.java
public void initFromConf() throws LinphoneConfigException, LinphoneException { // traces/*from w w w .j a va 2 s. c o m*/ 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:cn.kangeqiu.kq.activity.ChatActivity.java
private void setUpView() { activityInstance = this; iv_emoticons_normal.setOnClickListener(this); iv_emoticons_checked.setOnClickListener(this); // position = getIntent().getIntExtra("position", -1); clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); manager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); wakeLock = ((PowerManager) getSystemService(Context.POWER_SERVICE)) .newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "demo"); roomId = getIntent().getStringExtra("roomId"); // ???// w w w . j a va2s . c o m chatType = getIntent().getIntExtra("chatType", CHATTYPE_SINGLE); if (chatType == CHATTYPE_SINGLE) { // ?? findViewById(R.id.container_dadu).setVisibility(View.GONE); findViewById(R.id.container_jingcai).setVisibility(View.GONE); toChatUsername = getIntent().getStringExtra("userId"); String nickname = getIntent().getStringExtra("nickname"); ((TextView) findViewById(R.id.name)).setText(nickname); // conversation = // EMChatManager.getInstance().getConversation(toChatUsername,false); } else { // ? findViewById(R.id.container_to_group).setVisibility(View.VISIBLE); findViewById(R.id.container_remove).setVisibility(View.GONE); findViewById(R.id.container_voice_call).setVisibility(View.GONE); findViewById(R.id.container_video_call).setVisibility(View.GONE); findViewById(R.id.container_file).setVisibility(View.GONE); // findViewById(R.id.container_photo).setVisibility(View.GONE); findViewById(R.id.container_location).setVisibility(View.GONE); findViewById(R.id.container_video).setVisibility(View.GONE); findViewById(R.id.score_lay).setVisibility(View.VISIBLE); toChatUsername = getIntent().getStringExtra("groupId"); group = EMGroupManager.getInstance().getGroup(toChatUsername); ((TextView) findViewById(R.id.name)).setText(group.getGroupName()); // conversation = // EMChatManager.getInstance().getConversation(toChatUsername,true); doPullDate("2061", new MCHttpCallBack() { @Override public void onSuccess(MCHttpResp resp) { super.onSuccess(resp); try { String resultCode = resp.getJson().getString("result_code"); if (resultCode.equals("0")) { match = resp.getJson().getJSONObject("match"); loader.LoadImage( resp.getJson().getJSONObject("match").getJSONObject("team1").getString("icon"), team_icon1); loader.LoadImage( resp.getJson().getJSONObject("match").getJSONObject("team2").getString("icon"), team_icon2); score_textView.setText( resp.getJson().getJSONObject("match").getJSONObject("team1").getString("score") + ":" + resp.getJson().getJSONObject("match").getJSONObject("team2") .getString("score")); String stateStr = ""; String stateJson = resp.getJson().getJSONObject("match").getString("state"); if (stateJson.equals("0")) { stateStr = ""; } else if (stateJson.equals("1")) { stateStr = ""; } else if (stateJson.equals("2")) { stateStr = "?"; } tv_state.setText(stateStr); // private CircleImageView team_icon1, team_icon2; // private TextView tv_state, score_textView; } else { Toast.makeText(getApplicationContext(), resp.getJson().getString("message"), Toast.LENGTH_SHORT).show(); } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } @Override public void onError(MCHttpResp resp) { super.onError(resp); } }); } conversation = EMChatManager.getInstance().getConversation(toChatUsername); // ?0 conversation.resetUnreadMsgCount(); adapter = new MessageAdapter(this, toChatUsername, chatType); // ? listView.setAdapter(adapter); listView.setOnScrollListener(new ListScrollListener()); int count = listView.getCount(); if (count > 0) { listView.setSelection(count - 1); } listView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { hideKeyboard(); more.setVisibility(View.GONE); iv_emoticons_normal.setVisibility(View.VISIBLE); iv_emoticons_checked.setVisibility(View.INVISIBLE); emojiIconContainer.setVisibility(View.GONE); btnContainer.setVisibility(View.GONE); return false; } }); // ? receiver = new NewMessageBroadcastReceiver(); IntentFilter intentFilter = new IntentFilter(EMChatManager.getInstance().getNewMessageBroadcastAction()); // Mainacitivity,??chat?????? intentFilter.setPriority(5); registerReceiver(receiver, intentFilter); // ack?BroadcastReceiver IntentFilter ackMessageIntentFilter = new IntentFilter( EMChatManager.getInstance().getAckMessageBroadcastAction()); ackMessageIntentFilter.setPriority(5); registerReceiver(ackMessageReceiver, ackMessageIntentFilter); // ??BroadcastReceiver IntentFilter deliveryAckMessageIntentFilter = new IntentFilter( EMChatManager.getInstance().getDeliveryAckMessageBroadcastAction()); deliveryAckMessageIntentFilter.setPriority(5); registerReceiver(deliveryAckMessageReceiver, deliveryAckMessageIntentFilter); // ????T groupListener = new GroupListener(); EMGroupManager.getInstance().addGroupChangeListener(groupListener); // show forward message if the message is not null String forward_msg_id = getIntent().getStringExtra("forward_msg_id"); if (forward_msg_id != null) { // ????? forwardMessage(forward_msg_id); } }
From source file:edu.missouri.bas.service.SensorService.java
private void prepareAlarms() { IntentFilter locationSchedulerFilter = new IntentFilter(ACTION_SCHEDULE_LOCATION); IntentFilter locationInterruptSchedulerFilter = new IntentFilter(ACTION_STOP_LOCATIONCONTROL); IntentFilter surveyScheduleFilter = new IntentFilter(ACTION_SCHEDULE_SURVEY); IntentFilter surveyTest = new IntentFilter("ACTION_SURVEY_TEST"); //ADD INTENTFILTER FOR DRINKING-FOLLOWUP IntentFilter followUpFilter = new IntentFilter(ACTION_DRINK_FOLLOWUP); /* Intent scheduleLocationIntent = new Intent(SensorService.ACTION_SCHEDULE_LOCATION); scheduleLocation = PendingIntent.getBroadcast( serviceContext, 0, scheduleLocationIntent, 0); mAlarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + 10000, 1000 * 60 * 5, scheduleLocation);*/ IntentFilter soundRequest = new IntentFilter(ACTION_START_SOUND); IntentFilter checkRequest = new IntentFilter(ACTION_SCHEDULE_CHECK); IntentFilter startSensors = new IntentFilter(ACTION_START_SENSORS); IntentFilter locationFoundFilter = new IntentFilter(LocationControl.INTENT_ACTION_LOCATION); IntentFilter sound1 = new IntentFilter(ACTION_TRIGGER_SOUND); IntentFilter sound2 = new IntentFilter(ACTION_TRIGGER_SOUND2); SensorService.this.registerReceiver(alarmReceiver, locationFoundFilter); SensorService.this.registerReceiver(alarmReceiver, locationSchedulerFilter); SensorService.this.registerReceiver(alarmReceiver, locationInterruptSchedulerFilter); SensorService.this.registerReceiver(alarmReceiver, surveyScheduleFilter); SensorService.this.registerReceiver(alarmReceiver, surveyTest); //Register the drink-followup to the alarmReceiver SensorService.this.registerReceiver(alarmReceiver, followUpFilter); SensorService.this.registerReceiver(soundRequestReceiver, soundRequest); SensorService.this.registerReceiver(soundRequestReceiver, sound1); SensorService.this.registerReceiver(soundRequestReceiver, sound2); SensorService.this.registerReceiver(checkRequestReceiver, checkRequest); SensorService.this.registerReceiver(checkRequestReceiver, startSensors); IntentFilter chestSensorData = new IntentFilter(ACTION_CONNECT_CHEST); SensorService.this.registerReceiver(chestSensorReceiver, chestSensorData); }
From source file:ca.mcgill.hs.serv.LogFileUploaderService.java
/** * Runs a new thread that uploads all files in the fileList. *//*w ww . j a va2 s .c om*/ private void uploadFiles() { new Thread() { @Override public void run() { updateFileList(); String ff = null; while (!fileList.isEmpty()) { if (canUpload()) { final String f = fileList.remove(); final int retCode = uploadFile(f); if (retCode != NO_ERROR_CODE) { // If the file is missing, or there is some problem // reading the file, then the file is skipped. // Otherwise it is put back into the queue. if (retCode != UPLOAD_FAILED_FILE_NOT_FOUND_ERROR_CODE && retCode != IOEXCEPTION_ERROR_CODE) { fileList.addLast(f); if (ff == null) { ff = f; } else { // If we have gone through the whole list // and all files are giving errors, if on // automatic set the timer to try again, // else break and alert user that there were // errors. if (ff.equals(f)) { if (automatic) { waiting = true; // We are waiting to try the upload // for this file again after a set // time. timerStart(); return; } else { break; } } } } } else { // If there was no error code, the file was // successfully uploaded. filesUploaded++; } } else { if (automatic) { waiting = true; // We now wait for a connection to become available, // so register a receiver for it. registerReceiver(connectReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION)); connectionReceiverRegistered = true; return; } else { CURRENT_ERROR_CODE = NO_CONNECTION_ERROR; break; } } } fileMap.clear(); fileList.clear(); if (httpclient != null) { httpclient.getConnectionManager().shutdown(); } final Intent i = new Intent(); i.setAction(UPLOAD_COMPLETE_INTENT); sendBroadcast(i); } }.start(); }
From source file:com.xorcode.andtweet.AndTweetService.java
@Override public void onCreate() { MyPreferences.initialize(this, this); preferencesChangeTime = MyPreferences.getDefaultSharedPreferences() .getLong(MyPreferences.KEY_PREFERENCES_CHANGE_TIME, 0); preferencesExamineTime = getServiceSp().getLong(MyPreferences.KEY_PREFERENCES_EXAMINE_TIME, 0); MyLog.d(TAG, "Service created, preferencesChangeTime=" + preferencesChangeTime + ", examined=" + preferencesExamineTime);/*from www . ja v a 2s. co m*/ registerReceiver(intentReceiver, new IntentFilter(ACTION_GO)); }
From source file:com.easemob.chatuidemo.ui.MainActivity.java
/** * ??/*ww w . j a va 2 s . co m*/ */ private void registerInternalDebugReceiver() { internalDebugReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { DemoHelper.getInstance().logout(false, new EMCallBack() { @Override public void onSuccess() { runOnUiThread(new Runnable() { public void run() { // ?? finish(); startActivity(new Intent(MainActivity.this, LoginActivity.class)); } }); } @Override public void onProgress(int progress, String status) { } @Override public void onError(int code, String message) { } }); } }; IntentFilter filter = new IntentFilter(getPackageName() + ".em_internal_debug"); registerReceiver(internalDebugReceiver, filter); }
From source file:org.gaeproxy.GAEProxyService.java
@Override public void onCreate() { super.onCreate(); mShutdownReceiver = new BroadcastReceiver() { @Override/*w w w . j a v a 2 s . c o m*/ public void onReceive(Context context, Intent intent) { stopSelf(); } }; IntentFilter filter = new IntentFilter(Intent.ACTION_SHUTDOWN); registerReceiver(mShutdownReceiver, filter); EasyTracker.getTracker().trackEvent("service", "start", getVersionName(), 0L); notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); settings = PreferenceManager.getDefaultSharedPreferences(this); Intent intent = new Intent(this, GAEProxyActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); pendIntent = PendingIntent.getActivity(this, 0, intent, 0); notification = new Notification(); try { mStartForeground = getClass().getMethod("startForeground", mStartForegroundSignature); mStopForeground = getClass().getMethod("stopForeground", mStopForegroundSignature); } catch (NoSuchMethodException e) { // Running on an older platform. mStartForeground = mStopForeground = null; } try { mSetForeground = getClass().getMethod("setForeground", mSetForegroundSignature); } catch (NoSuchMethodException e) { throw new IllegalStateException("OS doesn't have Service.startForeground OR Service.setForeground!"); } }
From source file:org.wso2.emm.agent.utils.CommonUtils.java
public static void registerSystemAppReceiver(Context context) { IntentFilter filter = new IntentFilter(Constants.SYSTEM_APP_BROADCAST_ACTION); filter.addCategory(Intent.CATEGORY_DEFAULT); SystemServiceResponseReceiver receiver = new SystemServiceResponseReceiver(); context.registerReceiver(receiver, filter); }