List of usage examples for android.content IntentFilter IntentFilter
public IntentFilter()
From source file:com.ec.android.module.bluetooth40.base.BaseBluetoothControlActivity.java
private static IntentFilter makeGattUpdateIntentFilter() { final IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(BluetoothLeService.ACTION_GATT_ERROR); intentFilter.addAction(BluetoothLeService.ACTION_GATT_CONNECTED); intentFilter.addAction(BluetoothLeService.ACTION_GATT_DISCONNECTED); intentFilter.addAction(BluetoothLeService.ACTION_GATT_SERVICES_DISCOVERED); intentFilter.addAction(BluetoothLeService.ACTION_DATA_AVAILABLE); return intentFilter; }
From source file:by.zatta.pilight.connection.ConnectionService.java
@Override public void onCreate() { Log.v(TAG, "onCreate"); super.onCreate(); ctx = this;/* w ww .ja va 2 s . c o m*/ aCtx = getApplicationContext(); SharedPreferences getPrefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext()); String language = getPrefs.getString("languagePref", "unknown"); if (!language.equals("unknown")) makeLocale(language); IntentFilter filter = new IntentFilter(); filter.addAction("pilight-reconnect"); filter.addAction("pilight-kill-service"); filter.addAction("pilight-switch-device"); this.registerReceiver(mMessageReceiver, filter); mNotMan = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); isConnectionUp = makeConnection(); isDestroying = false; Log.v(TAG, "onCreate done"); }
From source file:com.trimble.mcs.cordova.plugin.TrmbMcsRfid.java
@Override public void initialize(CordovaInterface cordova, CordovaWebView webView) { super.initialize(cordova, webView); // Create broadcast receiver to receive RFID scan intents mRfidTagReceiver = new BroadcastReceiver() { public void onReceive(Context context, Intent intent) { handleRfidTagIntent(context, intent); }/*w ww . j a va2s . c om*/ }; mRfidTagFilter = new IntentFilter(); mRfidTagFilter.addAction(RfidConstants.ACTION_RFID_TAG_SCANNED); // Create broadcast receiver to receive RFID scan status mRfidStatusReceiver = new BroadcastReceiver() { public void onReceive(Context context, Intent intent) { handleRfidStatusIntent(context, intent); } }; mRfidStatusFilter = new IntentFilter(); mRfidStatusFilter.addAction(RfidConstants.ACTION_RFID_START_SCAN_NOTIFICATION); mRfidStatusFilter.addAction(RfidConstants.ACTION_RFID_STOP_SCAN_NOTIFICATION); }
From source file:com.physicaroid.pocketduino.cordova.PocketDuino.java
/** * USB???// w ww . j a v a2 s .c o m */ private void listenUsbDevice(CallbackContext callbackContext) { IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(UsbManager.ACTION_USB_DEVICE_ATTACHED); intentFilter.addAction(UsbManager.ACTION_USB_DEVICE_DETACHED); this.usbCallbackContext = callbackContext; if (this.mUsbReceiver == null) { this.mUsbReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { String handlerName = null; String action = intent.getAction(); if (UsbManager.ACTION_USB_DEVICE_ATTACHED.equals(action)) { // plugin result of USB attached handlerName = HANDLER_PREFIX + "." + "attached"; } if (UsbManager.ACTION_USB_DEVICE_DETACHED.equals(action)) { // plugin result of USB detached handlerName = HANDLER_PREFIX + "." + "detached"; } try { String json = "{\"handlerName\":" + handlerName + " }"; JSONObject parameter = new JSONObject(json); PluginResult dataResult = new PluginResult(PluginResult.Status.OK, parameter); dataResult.setKeepCallback(true); usbCallbackContext.sendPluginResult(dataResult); } catch (JSONException e) { Log.e(POCKETDUINO, "Exception: " + e.getMessage()); usbCallbackContext.error(e.toString()); } } }; webView.getContext().registerReceiver(this.mUsbReceiver, intentFilter); } }
From source file:com.mobicage.rogerthat.registration.YSAAARegistrationActivity.java
@Override protected void onServiceBound() { setContentView(R.layout.ysaaa_registration); mWiz = YSAAARegistrationWizard.getWizard(mService, Installation.id(this)); if (CloudConstants.USE_GCM_KICK_CHANNEL && GoogleServicesUtils.checkPlayServices(this, true)) { GoogleServicesUtils.registerGCMRegistrationId(mService, new GCMRegistrationIdFoundCallback() { @Override/*from ww w . ja v a2s. c o m*/ public void idFound(String registrationId) { mGCMRegistrationId = registrationId; } }); } mStatusLbl = (TextView) findViewById(R.id.status); mProgressBar = (ProgressBar) findViewById(R.id.progressBar); mTimer = new Timer(false); mRetryBtn = (Button) findViewById(R.id.retry_button); mRetryBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { register(); } }); final String[] receivingIntents = new String[] { FriendsPlugin.FRIENDS_LIST_REFRESHED, FriendsPlugin.FRIEND_UPDATE_INTENT, FriendsPlugin.FRIEND_ADDED_INTENT, BrandingMgr.SERVICE_BRANDING_AVAILABLE_INTENT, BrandingMgr.GENERIC_BRANDING_AVAILABLE_INTENT }; IntentFilter filter = new IntentFilter(); for (String action : receivingIntents) filter.addAction(action); registerReceiver(new SafeBroadcastReceiver() { @Override public String[] onSafeReceive(Context context, Intent intent) { T.UI(); launchMainActivityAndFinishIfAppReady(); return receivingIntents; }; }, filter); register(); }
From source file:name.gumartinm.weather.information.fragment.current.CurrentFragment.java
@Override public void onResume() { super.onResume(); this.mReceiver = new BroadcastReceiver() { @Override//from ww w . j a va2 s .c o m public void onReceive(final Context context, final Intent intent) { final String action = intent.getAction(); if (action.equals(BROADCAST_INTENT_ACTION)) { final Current currentRemote = (Current) intent.getSerializableExtra("current"); // 1. Check conditions. They must be the same as the ones that triggered the AsyncTask. final DatabaseQueries query = new DatabaseQueries(context.getApplicationContext()); final WeatherLocation weatherLocation = query.queryDataBase(); final PermanentStorage store = new PermanentStorage(context.getApplicationContext()); final Current current = store.getCurrent(); if (current == null || !CurrentFragment.this.isDataFresh(weatherLocation.getLastCurrentUIUpdate())) { if (currentRemote != null) { // 2. Update UI. CurrentFragment.this.updateUI(currentRemote); // 3. Update current data. store.saveCurrent(currentRemote); // 4. Update location data. weatherLocation.setLastCurrentUIUpdate(new Date()); query.updateDataBase(weatherLocation); } else { // Empty UI and show error message CurrentFragment.this.getActivity().findViewById(R.id.weather_current_data_container) .setVisibility(View.GONE); CurrentFragment.this.getActivity().findViewById(R.id.weather_current_progressbar) .setVisibility(View.GONE); CurrentFragment.this.getActivity().findViewById(R.id.weather_current_error_message) .setVisibility(View.VISIBLE); } } } } }; // Register receiver final IntentFilter filter = new IntentFilter(); filter.addAction(BROADCAST_INTENT_ACTION); LocalBroadcastManager.getInstance(this.getActivity().getApplicationContext()) .registerReceiver(this.mReceiver, filter); // Empty UI this.getActivity().findViewById(R.id.weather_current_data_container).setVisibility(View.GONE); final DatabaseQueries query = new DatabaseQueries(this.getActivity().getApplicationContext()); final WeatherLocation weatherLocation = query.queryDataBase(); if (weatherLocation == null) { // Nothing to do. // Show error message final ProgressBar progress = (ProgressBar) getActivity().findViewById(R.id.weather_current_progressbar); progress.setVisibility(View.GONE); final TextView errorMessage = (TextView) getActivity().findViewById(R.id.weather_current_error_message); errorMessage.setVisibility(View.VISIBLE); return; } // If is new location update widgets. if (weatherLocation.getIsNew()) { WidgetProvider.refreshAllAppWidgets(this.getActivity().getApplicationContext()); // Update location data. weatherLocation.setIsNew(false); query.updateDataBase(weatherLocation); } final PermanentStorage store = new PermanentStorage(this.getActivity().getApplicationContext()); final Current current = store.getCurrent(); if (current != null && this.isDataFresh(weatherLocation.getLastCurrentUIUpdate())) { this.updateUI(current); } else { // Load remote data (asynchronous) // Gets the data from the web. this.getActivity().findViewById(R.id.weather_current_progressbar).setVisibility(View.VISIBLE); this.getActivity().findViewById(R.id.weather_current_error_message).setVisibility(View.GONE); final CurrentTask task = new CurrentTask(this.getActivity().getApplicationContext(), new CustomHTTPClient(AndroidHttpClient.newInstance(this.getString(R.string.http_client_agent))), new ServiceCurrentParser(new JPOSCurrentParser())); task.execute(weatherLocation.getLatitude(), weatherLocation.getLongitude()); } }
From source file:com.umeng.message.example.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); pushDao = PushDao.getInstance(this); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); DisplayMetrics dm = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(dm); screenWidth = dm.widthPixels;/*from w w w . j a v a 2 s . c o m*/ setContentView(R.layout.activity_main); printKeyValue(); mPushAgent = PushAgent.getInstance(this); mPushAgent.onAppStart(); mPushAgent.enable(MyApplication.mRegisterCallback); tvStatus = (TextView) findViewById(R.id.tvStatus); btnEnable = (ImageView) findViewById(R.id.btnEnable); btnaAddTag = (Button) findViewById(R.id.btnAddTags); btnAddAlias = (Button) findViewById(R.id.btnAddAlias); btnListTag = (Button) findViewById(R.id.btnListTags); infoTextView = (TextView) findViewById(R.id.info); edTag = (EditText) findViewById(R.id.edTag); edAlias = (EditText) findViewById(R.id.edAlias); edAliasType = (EditText) findViewById(R.id.edAliasType); spAliasType = (Spinner) findViewById(R.id.spAliasType); edAliasType.setOnFocusChangeListener(new android.view.View.OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { edAliasTypeFocus = true; } else { edAliasTypeFocus = false; } } }); edAliasType.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // TODO Auto-generated method stub } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { // TODO Auto-generated method stub if (edAliasTypeFocus) { spAliasType.setSelection(0); } } @Override public void afterTextChanged(Editable s) { // TODO Auto-generated method stub } }); String[] aliasType = new String[] { "Alias Type:", ALIAS_TYPE.SINA_WEIBO, ALIAS_TYPE.BAIDU, ALIAS_TYPE.KAIXIN, ALIAS_TYPE.QQ, ALIAS_TYPE.RENREN, ALIAS_TYPE.TENCENT_WEIBO, ALIAS_TYPE.WEIXIN }; ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_single_choice, aliasType); spAliasType.setAdapter(adapter); spAliasType.setBackgroundColor(Color.LTGRAY); spAliasType.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) { // TODO Auto-generated method stub TextView tv = (TextView) arg1; if (tv != null) { int rate = (int) (5.0f * (float) screenWidth / 320.0f); int textSize = rate < 15 ? 15 : rate; tv.setTextSize((float) textSize); } if (arg2 != 0) { String type = (String) spAliasType.getItemAtPosition(arg2); edAliasType.setText(type); } else if (!edAliasTypeFocus) { edAliasType.setText(""); } } @Override public void onNothingSelected(AdapterView<?> arg0) { // TODO Auto-generated method stub } }); tvStatus.setOnClickListener(clickListener); btnEnable.setOnClickListener(clickListener); btnaAddTag.setOnClickListener(clickListener); btnListTag.setOnClickListener(clickListener); btnAddAlias.setOnClickListener(clickListener); updateStatus(); mPushAgent.setPushIntentServiceClass(MyPushIntentService.class); callbackReceiver = new CallbackReceiver(); IntentFilter filter = new IntentFilter(); filter.addAction(MyApplication.CALLBACK_RECEIVER_ACTION); registerReceiver(callbackReceiver, filter); }
From source file:fr.bmartel.android.fadecandy.service.FadecandyService.java
/** * Initialize broadcast receiver to receive USB ATTACHED/DETACHED events. *//*from w w w. jav a 2 s . c om*/ private void initBroadcastReceiver() { IntentFilter filter = new IntentFilter(); filter.addAction(ACTION_USB_PERMISSION); filter.addAction(UsbEventReceiverActivity.ACTION_USB_DEVICE_ATTACHED); filter.addAction(UsbManager.ACTION_USB_DEVICE_DETACHED); filter.addAction(FadecandyService.ACTION_EXIT); registerReceiver(receiver, filter); }
From source file:com.oo58.game.texaspoker.AppActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // this.getWindow().setFlags(FLAG_HOMEKEY_DISPATCHED, FLAG_HOMEKEY_DISPATCHED);// setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); mContext = AppActivity.this; try {//from ww w . ja v a 2s . com ApplicationInfo appInfo = this.getPackageManager().getApplicationInfo(getPackageName(), PackageManager.GET_META_DATA); String msg = appInfo.metaData.getString("data_Name"); // int channelid = Integer.parseInt(msg) ; // // System.out.println(channelid); } catch (NameNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } mAct = this; allContext = this.getApplicationContext(); mTencent = Tencent.createInstance("1104823392", getApplicationContext()); PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); mWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "MyLock"); mWakeLock.acquire(); MobclickAgent.setDebugMode(false); MobclickAgent.updateOnlineConfig(this); AnalyticsConfig.enableEncrypt(true); checkUpdate(); PackageManager pm2 = getPackageManager(); homeInfo = pm2.resolveActivity(new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME), 0); mNetChecker.initAndRegListener(mContext); mWXPay.init(this); MobClickCppHelper.init(this); // // logcatdebug // XGPushConfig.enableDebug(this, true); // // registerPush(getApplicationContext(), XGIOperateCallback)callback // // registerPush(getApplicationContext(),account) // // // // ApplicationContext // Context context = getApplicationContext(); // XGPushManager.registerPush(context); // // // 2.362 // Intent service = new Intent(context, XGPushService.class); // context.startService(service); // API // registerPush(context,account)registerPush(context,account, XGIOperateCallback)accountAPPqqopenid // registerPush(context,"*")account="*" // unregisterPush(context) // setTag(context, tagName) // deleteTag(context, tagName) updateListViewReceiver = new MsgReceiver(); IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction("com.oo58.game.texaspoker.activity.UPDATE_LISTVIEW"); registerReceiver(updateListViewReceiver, intentFilter); XGPushManager.registerPush(getApplicationContext(), new XGIOperateCallback() { @Override public void onSuccess(Object data, int flag) { // Log.w(Constants.LogTag, // "+++ register push sucess. token:" + data); } @Override public void onFail(Object data, int errCode, String msg) { // Log.w(Constants.LogTag, // "+++ register push fail. token:" + data // + ", errCode:" + errCode + ",msg:" // + msg); } }); //javajosnC++demo /* JSONObject jsonObj = new JSONObject(); try { jsonObj.put("Int_att",25); jsonObj.put("String_att","str");//string jsonObj.put("Double_att",12.25);//double jsonObj.put("Boolean_att",true);//boolean } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); }//int PushJson(jsonObj.toString()) ;*/ }