List of usage examples for android.content IntentFilter addAction
public final void addAction(String action)
From source file:com.DorsetEggs.waver.communicatorService.java
/** * The IntentService calls this method from the default worker thread with * the intent that started the service. When this method returns, IntentService * stops the service, as appropriate.//from w w w .ja v a2 s .c o m */ @Override protected void onHandleIntent(Intent intent) { //Using the the flag to decide if this is a singleton sendDebugMessage("Intent handled, active == true"); /*if(!active)*/ { //android.os.Debug.waitForDebugger(); callOngoing = false; sendDebugMessage("Waiting for connection"); instantiateAnimation(); mUsbManager = UsbManager.getInstance(this); mPermissionIntent = PendingIntent.getBroadcast(this, 0, new Intent(ACTION_USB_PERMISSION), 0); IntentFilter usbFilter = new IntentFilter(ACTION_USB_PERMISSION); usbFilter.addAction(UsbManager.ACTION_USB_ACCESSORY_DETACHED); registerReceiver(mUsbReceiver, usbFilter); IntentFilter callFilter = new IntentFilter(TelephonyManager.ACTION_PHONE_STATE_CHANGED); registerReceiver(mCallReceiver, callFilter); if (mAccessory != null) { setConnectionStatus(true); return; } UsbAccessory[] accessories = mUsbManager.getAccessoryList(); UsbAccessory accessory = (accessories == null ? null : accessories[0]); if (accessory != null) { sendDebugMessage("USB ready"); if (mUsbManager.hasPermission(accessory)) { openAccessory(accessory); active = true; launchNotification(mId, "Indi connected"); resetMotors(); //Initialise the database SQLiteDatabase db = globals.dbHelper.getWritableDatabase(); } else { setConnectionStatus(false); synchronized (mUsbReceiver) { if (!mPermissionRequestPending) { mUsbManager.requestPermission(accessory, mPermissionIntent); mPermissionRequestPending = true; } } } } else { setConnectionStatus(false); if (D) sendDebugMessage("mAccessory is null"); } // Play here until the phone is disconnected while (true) ; } }
From source file:com.koma.music.play.MusicPlayerFragment.java
private void registerPlaybackStatusReceiver() { IntentFilter filter = new IntentFilter(); // if a queue has changed,notify us // filter.addAction(MusicServiceConstants.QUEUE_CHANGED); // Play and pause changes filter.addAction(MusicServiceConstants.PLAYSTATE_CHANGED); // Track changes filter.addAction(MusicServiceConstants.META_CHANGED); // Update a list, probably the playlist fragment's // filter.addAction(MusicServiceConstants.REFRESH); // If a playlist has changed, notify us filter.addAction(MusicServiceConstants.PLAYLIST_CHANGED); // If there is an error playing a track filter.addAction(MusicServiceConstants.TRACK_ERROR); filter.addAction(MusicServiceConstants.SHUFFLEMODE_CHANGED); filter.addAction(MusicServiceConstants.REPEATMODE_CHANGED); mContext.registerReceiver(mPlaybackStatus, filter); }
From source file:com.alibaba.weex.WXPageActivity.java
private void registerBroadcastReceiver() { mReceiver = new RefreshBroadcastReceiver(); IntentFilter filter = new IntentFilter(); filter.addAction(IWXDebugProxy.ACTION_DEBUG_INSTANCE_REFRESH); registerReceiver(mReceiver, filter); }
From source file:com.cerema.cloud2.ui.activity.FolderPickerActivity.java
@Override protected void onResume() { super.onResume(); Log_OC.e(TAG, "onResume() start"); // refresh list of files refreshListOfFilesFragment();//from w ww . j av a 2 s .c om // Listen for sync messages IntentFilter syncIntentFilter = new IntentFilter(FileSyncAdapter.EVENT_FULL_SYNC_START); syncIntentFilter.addAction(FileSyncAdapter.EVENT_FULL_SYNC_END); syncIntentFilter.addAction(FileSyncAdapter.EVENT_FULL_SYNC_FOLDER_CONTENTS_SYNCED); syncIntentFilter.addAction(RefreshFolderOperation.EVENT_SINGLE_FOLDER_CONTENTS_SYNCED); syncIntentFilter.addAction(RefreshFolderOperation.EVENT_SINGLE_FOLDER_SHARES_SYNCED); mSyncBroadcastReceiver = new SyncBroadcastReceiver(); registerReceiver(mSyncBroadcastReceiver, syncIntentFilter); Log_OC.d(TAG, "onResume() end"); }
From source file:com.brandroidtools.filemanager.activities.PickerActivity.java
/** * {@inheritDoc}/* www. j a v a 2s . com*/ */ @Override protected void onCreate(Bundle state) { if (DEBUG) { Log.d(TAG, "PickerActivity.onCreate"); //$NON-NLS-1$ } // Register the broadcast receiver IntentFilter filter = new IntentFilter(); filter.addAction(FileManagerSettings.INTENT_THEME_CHANGED); registerReceiver(this.mNotificationReceiver, filter); // Initialize the activity init(); //Save state super.onCreate(state); }
From source file:com.baruckis.nanodegree.spotifystreamer.PlayerService.java
@Override public void onCreate() { //create the service super.onCreate(); //create mMediaPlayer mMediaPlayer = new MediaPlayer(); //initialize//from w w w. j a v a2 s . c o m trackPosition = 0; initMediaPlayer(); initMediaSession(); //Notification visibility (show controls on the lock screen or not) SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); mShowNotification = prefs.getBoolean(getString(R.string.switch_preference_notification_key), getResources().getBoolean(R.bool.default_show_notification)); IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(RECEIVE_BROADCAST_INTENT_PAUSE); intentFilter.addAction(RECEIVE_BROADCAST_INTENT_NOTIFICATION); LocalBroadcastManager.getInstance(this).registerReceiver(mBroadcastReceiver, intentFilter); }
From source file:br.liveo.ndrawer.ui.activity.MainActivity.java
License:asdf
private static IntentFilter makeGattUpdateIntentFilter() { final IntentFilter fi = new IntentFilter(); fi.addAction(ACTION_GATT_SERVICES_DISCOVERED); fi.addAction(ACTION_DATA_NOTIFY);/*from w w w .ja v a 2 s .c o m*/ fi.addAction(ACTION_DATA_WRITE); fi.addAction(ACTION_DATA_READ); fi.addAction(DeviceInformationServiceProfile.ACTION_FW_REV_UPDATED); fi.addAction(TIOADProfile.ACTION_PREPARE_FOR_OAD); return fi; }
From source file:com.concentricsky.android.khanacademy.app.TopicListActivity.java
@Override protected void onStart() { super.onStart(); stopped = false;//from ww w . j av a 2 s . co m mainMenuDelegate = new MainMenuDelegate(this); gridView = (GridView) findViewById(R.id.activity_topic_list_grid); gridView.setOnItemClickListener(clickListener); ActionBar ab = getActionBar(); ab.setDisplayHomeAsUpEnabled(true); ab.setTitle("Topics"); requestDataService(new ObjectCallback<KADataService>() { @Override public void call(final KADataService dataService) { TopicListActivity.this.dataService = dataService; try { thumbnailManager = dataService.getThumbnailManager(); dao = dataService.getHelper().getTopicDao(); if (topicId != null) { topic = dao.queryForId(topicId); } else { topic = dataService.getRootTopic(); topicId = topic.getId(); } // DEBUG if (topic == null) return; // header headerView = findViewById(R.id.header_topic_list); ((TextView) headerView.findViewById(R.id.header_video_list_title)).setText(topic.getTitle()); String desc = topic.getDescription(); TextView descView = (TextView) headerView.findViewById(R.id.header_video_list_description); if (desc != null && desc.length() > 0) { descView.setText(Html.fromHtml(desc)); descView.setVisibility(View.VISIBLE); } else { descView.setVisibility(View.GONE); } // Find child count for this parent topic. boolean videoChildren = Topic.CHILD_KIND_VIDEO.equals(topic.getChild_kind()); String[] idArg = { topic.getId() }; String sql = videoChildren ? "select count() from topicvideo where topic_id=?" : "select count() from topic where parentTopic_id=?"; int count = (int) dao.queryRawValue(sql, idArg); String countFormat = getString( videoChildren ? R.string.format_video_count : R.string.format_topic_count); // Set header count string. ((TextView) headerView.findViewById(R.id.header_video_list_count)) .setText(String.format(countFormat, count)); final ImageView thumb = (ImageView) headerView.findViewById(R.id.header_video_list_thumbnail); if (thumb != null) { new AsyncTask<Void, Void, Bitmap>() { @Override public Bitmap doInBackground(Void... arg) { Bitmap bmp = thumbnailManager.getThumbnail( TopicListActivity.this.topic.getThumb_id(), Thumbnail.QUALITY_SD); return bmp; } @Override public void onPostExecute(Bitmap bmp) { thumb.setImageBitmap(bmp); } }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } // list if (topicCursor != null) { topicCursor.close(); } topicCursor = buildCursor(topicId); ListAdapter adapter = new TopicGridAdapter(topicCursor); gridView.setAdapter(adapter); // Request the topic and its children be updated from the api. List<Topic> children = dao.queryForEq("parentTopic_id", topic.getId()); List<String> toUpdate = new ArrayList<String>(); for (Topic child : children) { toUpdate.add(child.getId()); } toUpdate.add(topic.getId()); } catch (SQLException e) { e.printStackTrace(); } } }); IntentFilter filter = new IntentFilter(); filter.addAction(ACTION_LIBRARY_UPDATE); filter.addAction(ACTION_BADGE_EARNED); filter.addAction(ACTION_TOAST); LocalBroadcastManager.getInstance(this).registerReceiver(receiver, filter); }
From source file:com.example.robert.bluetoothnew.BluetoothChatFragment.java
public void intiBroadCast() { IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(MAP_ACTION); getActivity().registerReceiver(broadcast, intentFilter); broadcast = new Broadcast() { @Override/*from ww w . j a v a 2 s .com*/ public void position(LatLng latLng) { super.position(latLng); Log.v("latLng", "" + latLng); myWebView.loadUrl("javascript:test('Hello World!')"); } }; intentFilter.addAction(MAP_ACTION); getActivity().registerReceiver(broadcast, intentFilter); }
From source file:com.example.robert.bluetoothnew.BluetoothChatFragment.java
public void intiCallWeb() { IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(CallWeb); getActivity().registerReceiver(broadcast, intentFilter); broadcast = new Broadcast() { @Override//from ww w .ja v a 2 s . c o m public void callWeb(String type, String id) { super.callWeb(type, id); Log.v("WebViewActivity", "UA: " + myWebView.getSettings().getUserAgentString()); if (!type.equals("0")) { String call = "javascript:Navigation('" + type + "','" + id + "')"; myWebView.loadUrl(call); //javascript:[webFunctionName]([parameter]) } } }; intentFilter.addAction(MAP_ACTION); getActivity().registerReceiver(broadcast, intentFilter); }