List of usage examples for android.content IntentFilter addAction
public final void addAction(String action)
From source file:it.gmariotti.android.apps.dashclock.extensions.battery.BatteryExtension.java
@Override protected void onInitialize(boolean isReconnect) { super.onInitialize(isReconnect); readPreferences();//from w w w.jav a2 s . c o m if (onClickReceiver != null) { try { unregisterReceiver(onClickReceiver); } catch (Exception e) { } } IntentFilter intentFilter = new IntentFilter(REFRESH_INTENT_FILTER); onClickReceiver = new OnClickReceiver(); registerReceiver(onClickReceiver, intentFilter); IntentFilter filterScreen = new IntentFilter(); filterScreen.addAction(Intent.ACTION_SCREEN_ON); getApplicationContext().registerReceiver(mScreenOnReceiver, filterScreen); //scheduleRefresh(0); }
From source file:com.dwdesign.tweetings.fragment.CursorStatusesListFragment.java
@Override public void onStart() { super.onStart(); final IntentFilter filter = new IntentFilter(BROADCAST_ACCOUNT_LIST_DATABASE_UPDATED); filter.addAction(BROADCAST_FILTERS_UPDATED); filter.addAction(BROADCAST_TWITLONGER_EXPANDED); registerReceiver(mStatusReceiver, filter); }
From source file:com.afrolkin.samplepushclient.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(com.afrolkin.samplepushclient.R.layout.activity_main); // Layout element references registerButton = (Button) findViewById(R.id.register_button); unregisterButton = (Button) findViewById(R.id.unregister_button); registrationStatusTextView = (TextView) findViewById(R.id.registration_status); registrationIDTextView = (TextView) findViewById(R.id.registration_id); senderIDTextView = (TextView) findViewById(R.id.sender_id); // Register local receiver to receive broadcasts from GCMIntentService IntentFilter filter = new IntentFilter(getString(R.string.register_status_action)); filter.addAction(getString(R.string.push_message_action)); LocalBroadcastManager.getInstance(this).registerReceiver(messageReceiver, filter); registerButton.setOnClickListener(new View.OnClickListener() { @Override/*w w w . j a va 2 s .c o m*/ public void onClick(View v) { registerGcm(); } }); unregisterButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { unregisterGcm(); } }); checkSenderID(SENDER_ID); senderIDTextView.setText(SENDER_ID); // Try to register GCM on first open registerGcm(); }
From source file:com.javadog.bluetoothproximitylock.test.BluetoothFragmentTest.java
/** * Tests {@link com.javadog.bluetoothproximitylock.BluetoothFragment.LocalBroadcastReceiver#onReceive(android.content.Context, android.content.Intent)} *///from w w w . j av a 2 s. c o m public void testOnReceive() { ReceiverTest receiver = new ReceiverTest(); addFragment(receiver); LocalBroadcastManager manager = LocalBroadcastManager.getInstance(getInstrumentation().getTargetContext()); IntentFilter filter = new IntentFilter(); filter.addAction(SignalReaderService.ACTION_SIGNAL_STRENGTH_UPDATE); manager.registerReceiver(receiver.getReceiver(), filter); Intent testIntent = new Intent(SignalReaderService.ACTION_SIGNAL_STRENGTH_UPDATE); testIntent.putExtra("message", 6969); manager.sendBroadcast(testIntent); }
From source file:com.android.car.trust.CarEnrolmentActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.car_client); mOutputText = (TextView) findViewById(R.id.textfield); final Intent intent = new Intent(this, CarEnrolmentService.class); mPrefs = PreferenceManager.getDefaultSharedPreferences(this /* context */); IntentFilter filter = new IntentFilter(); filter.addAction(ACTION_TOKEN_STATUS_RESULT); filter.addAction(ACTION_ADD_TOKEN_RESULT); mLocalBroadcastManager = LocalBroadcastManager.getInstance(this /* context */); mLocalBroadcastManager.registerReceiver(mReceiver, filter); mStartButton = (Button) findViewById(R.id.start_button); mStartButton.setOnClickListener(new View.OnClickListener() { @Override/*from ww w.j a v a 2 s. c om*/ public void onClick(View v) { // binding the service will start it if not started. bindService(intent, mServiceConnection, Context.BIND_AUTO_CREATE); } }); Button revokeButton = (Button) findViewById(R.id.revoke_trust_button); revokeButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(CarBleTrustAgent.ACTION_REVOKE_TRUST); intent.setPackage(getPackageName()); sendBroadcast(intent); } }); }
From source file:com.toppatch.mv.ui.activities.LoginActivity2.java
private void enableAdmin() { DevicePolicyManager mDPM = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE); ComponentName mDeviceAdmin = new ComponentName(this, TopPatchAdmin.class); if (mDPM != null) { try {/*from w w w. jav a2 s .co m*/ //Add filter to listen to the choice made by the user to accept the terms or not. IntentFilter filter = new IntentFilter(); filter.addAction(EnterpriseLicenseManager.ACTION_LICENSE_STATUS); actionReceiver = new SamsungReceiver(); registerReceiver(actionReceiver, filter); Intent intent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN); intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, mDeviceAdmin); intent.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION, "Please Activate The Admin To Let Us Steal All Your Data And Sell It To Obama!"); startActivityForResult(intent, RESULT_ENABLE); } catch (Exception e) { Log.w(TAG, "Exception: " + e); } } else { Log.e(TAG, "mDPM is null"); //TODO device doesn't support MDM...report this shit. } }
From source file:com.google.android.car.kitchensink.bluetooth.MapMceTestFragment.java
void launchDevicePicker() { IntentFilter filter = new IntentFilter(); filter.addAction(BluetoothDevicePicker.ACTION_DEVICE_SELECTED); getContext().registerReceiver(mPickerReceiver, filter); Intent intent = new Intent(BluetoothDevicePicker.ACTION_LAUNCH); intent.setFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); getContext().startActivity(intent);/*from w w w.ja v a 2 s. c o m*/ }
From source file:app.hacked.ChatFragment.java
@Override public void onResume() { super.onResume(); Log.e("onResume", "Registering broadcast"); IntentFilter filter = new IntentFilter(); filter.addAction(BROADCAST_ACTION); getActivity().registerReceiver(receiver, filter); }
From source file:com.amaze.filemanager.fragments.AppsList.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setHasOptionsMenu(false);// ww w . j a v a 2 s. c om ic = new IconHolder(getActivity(), true, true); IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(Intent.ACTION_PACKAGE_ADDED); intentFilter.addAction(Intent.ACTION_PACKAGE_REMOVED); intentFilter.addDataScheme("package"); getActivity().registerReceiver(br, intentFilter); }
From source file:com.google.android.car.kitchensink.bluetooth.BluetoothHeadsetFragment.java
void launchDevicePicker() { IntentFilter filter = new IntentFilter(); filter.addAction(BluetoothDevicePicker.ACTION_DEVICE_SELECTED); getContext().registerReceiver(mPickerReceiver, filter); Intent intent = new Intent(DEVICE_PICKER_ACTION); intent.setFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); getContext().startActivity(intent);// ww w .j ava2 s. c o m }