List of usage examples for android.content IntentFilter addAction
public final void addAction(String action)
From source file:com.toppatch.mv.ui.activities.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { String TAG = "MainActivity.onCreate"; super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Intent intent = getIntent();/*w w w. ja v a 2 s . c o m*/ intent.getExtras(); Boolean bool = intent.getBooleanExtra("fromReciever", false); IntentFilter filter = new IntentFilter(); filter.addAction(EnterpriseLicenseManager.ACTION_LICENSE_STATUS); samsungReciever = new SamsungReceiver(); this.registerReceiver(samsungReciever, filter); if (bool == true) { acceptConditions = (Button) findViewById(R.id.acceptConditionsButton); acceptConditions.setText("Sorry you need to accept conditions to proceed...."); acceptConditions.setClickable(true); } else { Log.i("see", "oncreate"); checkConditions(); } }
From source file:com.google.example.gcmnetworkmanagerquickstart.MainActivity.java
@Override public void onStart() { super.onStart(); IntentFilter filter = new IntentFilter(); filter.addAction(MyTaskService.ACTION_DONE); LocalBroadcastManager manager = LocalBroadcastManager.getInstance(this); manager.registerReceiver(mReceiver, filter); }
From source file:com.hrs.filltheform.service.MyAccessibilityService.java
private void addCompanionActions(IntentFilter intentFilter) { intentFilter.addAction(FillTheFormCompanion.INTENT_READ_CONFIGURATION_FILE); intentFilter.addAction(FillTheFormCompanion.INTENT_HIDE_FILL_THE_FORM_DIALOG); intentFilter.addAction(FillTheFormCompanion.INTENT_SET_FAST_MODE); intentFilter.addAction(FillTheFormCompanion.INTENT_SET_NORMAL_MODE); intentFilter.addAction(FillTheFormCompanion.INTENT_REQUEST_NUMBER_OF_PROFILES); intentFilter.addAction(FillTheFormCompanion.INTENT_SELECT_NEXT_PROFILE); }
From source file:com.example.plugin.PhoneListener.java
public void initialize(CordovaInterface cordova, CordovaWebView webView) { super.initialize(cordova, webView); this.phoneListenerCallbackId = null; IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(TelephonyManager.ACTION_PHONE_STATE_CHANGED); if (this.receiver == null) { this.receiver = new BroadcastReceiver() { @Override/*from ww w .ja v a 2 s . com*/ public void onReceive(Context context, Intent intent) { if (intent != null && intent.getAction().equals(TelephonyManager.ACTION_PHONE_STATE_CHANGED)) { // State has changed String phoneState = intent.hasExtra(TelephonyManager.EXTRA_STATE) ? intent.getStringExtra(TelephonyManager.EXTRA_STATE) : null; String state; // See if the new state is 'ringing', 'off hook' or 'idle' if (phoneState != null && phoneState.equals(TelephonyManager.EXTRA_STATE_RINGING)) { // phone is ringing, awaiting either answering or canceling state = "RINGING"; Log.i(LOG_TAG, state); } else if (phoneState != null && phoneState.equals(TelephonyManager.EXTRA_STATE_OFFHOOK)) { // actually talking on the phone... either making a call or having answered one state = "OFFHOOK"; Log.i(LOG_TAG, state); } else if (phoneState != null && phoneState.equals(TelephonyManager.EXTRA_STATE_IDLE)) { // idle means back to no calls in or out. default state. state = "IDLE"; Log.i(LOG_TAG, state); } else { state = TYPE_NONE; Log.i(LOG_TAG, state); } updatePhoneState(state, true); } } }; // register the receiver... this is so it doesn't have to be added to AndroidManifest.xml cordova.getActivity().registerReceiver(this.receiver, intentFilter); this.registered = true; } }
From source file:com.phonegap.BatteryListener.java
/** * Executes the request and returns PluginResult. * /*from w w w. j a v a 2 s. c om*/ * @param action The action to execute. * @param args JSONArry of arguments for the plugin. * @param callbackId The callback id used when calling back into JavaScript. * @return A PluginResult object with a status and message. */ public PluginResult execute(String action, JSONArray args, String callbackId) { PluginResult.Status status = PluginResult.Status.INVALID_ACTION; String result = "Unsupported Operation: " + action; if (action.equals("start")) { if (this.batteryCallbackId != null) { return new PluginResult(PluginResult.Status.ERROR, "Battery listener already running."); } this.batteryCallbackId = callbackId; // We need to listen to power events to update battery status IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(Intent.ACTION_BATTERY_CHANGED); if (this.receiver == null) { this.receiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { updateBatteryInfo(intent); } }; ctx.registerReceiver(this.receiver, intentFilter); } // Don't return any result now, since status results will be sent when events come in from broadcast receiver PluginResult pluginResult = new PluginResult(PluginResult.Status.NO_RESULT); pluginResult.setKeepCallback(true); return pluginResult; } else if (action.equals("stop")) { removeBatteryListener(); this.sendUpdate(new JSONObject(), false); // release status callback in JS side this.batteryCallbackId = null; return new PluginResult(PluginResult.Status.OK); } return new PluginResult(status, result); }
From source file:com.actionbarsherlock.sample.demos.content.LocalServiceBroadcaster.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.local_service_broadcaster); // This is where we print the data we get back. final TextView callbackData = (TextView) findViewById(R.id.callback); // Put in some initial text. callbackData.setText("No broadcast received yet"); // We use this to send broadcasts within our local process. mLocalBroadcastManager = LocalBroadcastManager.getInstance(this); // We are going to watch for interesting local broadcasts. IntentFilter filter = new IntentFilter(); filter.addAction(ACTION_STARTED); filter.addAction(ACTION_UPDATE);//from www .j a v a2s. c om filter.addAction(ACTION_STOPPED); mReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if (intent.getAction().equals(ACTION_STARTED)) { callbackData.setText("STARTED"); } else if (intent.getAction().equals(ACTION_UPDATE)) { callbackData.setText("Got update: " + intent.getIntExtra("value", 0)); } else if (intent.getAction().equals(ACTION_STOPPED)) { callbackData.setText("STOPPED"); } } }; mLocalBroadcastManager.registerReceiver(mReceiver, filter); // Watch for button clicks. Button button = (Button) findViewById(R.id.start); button.setOnClickListener(mStartListener); button = (Button) findViewById(R.id.stop); button.setOnClickListener(mStopListener); }
From source file:ch.bfh.instacircle.ParticipantsListFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Subscribing to the participantJoined and participantChangedState // events to update immediately IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction("participantJoined"); intentFilter.addAction("participantChangedState"); LocalBroadcastManager.getInstance(getActivity()).registerReceiver(mMessageReceiver, intentFilter); // getting access to the database and query it helper = NetworkDbHelper.getInstance(getActivity()); cursor = helper.queryParticipants(); // initializing the adapter and assign it to myself pca = new ParticipantCursorAdapter(getActivity(), cursor); setListAdapter(pca);/* ww w.j a va2s . c o m*/ }
From source file:net.atlaslearning.cordova.OpenIn.OpenIn.java
/** * Executes the request.//from w w w.java2 s .com * * @param action The action to execute. * @param args JSONArry of arguments for the plugin. * @param callbackContext The callback context used when calling back into JavaScript. * @return True if the action was valid, false if not. */ public boolean execute(String action, JSONArray args, CallbackContext callbackContext) { if (action.equals("start")) { if (this.batteryCallbackContext != null) { callbackContext.error("Battery listener already running."); return true; } this.batteryCallbackContext = callbackContext; // We need to listen to power events to update battery status IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(Intent.ACTION_BATTERY_CHANGED); if (this.receiver == null) { this.receiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { updateBatteryInfo(intent); } }; cordova.getActivity().registerReceiver(this.receiver, intentFilter); } // Don't return any result now, since status results will be sent when events come in from broadcast receiver PluginResult pluginResult = new PluginResult(PluginResult.Status.NO_RESULT); pluginResult.setKeepCallback(true); callbackContext.sendPluginResult(pluginResult); return true; } else if (action.equals("stop")) { removeBatteryListener(); this.sendUpdate(new JSONObject(), false); // release status callback in JS side this.batteryCallbackContext = null; callbackContext.success(); return true; } return false; }
From source file:com.commonsware.android.downmgr.DownloadFragment.java
@Override public void onResume() { super.onResume(); IntentFilter f = new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE); f.addAction(DownloadManager.ACTION_NOTIFICATION_CLICKED); getActivity().registerReceiver(onEvent, f); }
From source file:com.example.parking.MobilePaymentActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent intent = getIntent();/*from w ww .ja v a 2 s.c om*/ mLicensePlateNumber = intent.getExtras().getString("licenseplate"); mLocationNumber = intent.getExtras().getInt("locationnumber"); mCarType = intent.getExtras().getString("cartype"); mParkType = intent.getExtras().getString("parktype"); mStartTime = intent.getExtras().getString("starttime"); mLeaveTime = intent.getExtras().getString("leavetime"); mExpense = intent.getExtras().getString("expense"); mPayType = intent.getExtras().getInt("paytype"); mDBAdapter = new DBAdapter(this); setContentView(R.layout.activity_mobile_payment); mTwoDimensionsCodeTitleTV = (TextView) findViewById(R.id.tv_mobile_payment_two_dimensions_code); mScanTitleTV = (TextView) findViewById(R.id.tv_mobile_payment_scan); mTwoDimensionsCodeTitleTV.setOnClickListener(mTabClickListener); mScanTitleTV.setOnClickListener(mTabClickListener); changeSelect(R.id.tv_mobile_payment_two_dimensions_code); changeFragment(R.id.tv_mobile_payment_two_dimensions_code); getActionBar().setDisplayHomeAsUpEnabled(true); IntentFilter filter = new IntentFilter(); filter.addAction("ExitApp"); filter.addAction("BackMain"); registerReceiver(mReceiver, filter); }