List of usage examples for android.content Intent getAction
public @Nullable String getAction()
From source file:com.money.manager.ex.sync.SyncSchedulerBroadcastReceiver.java
@Override public void onReceive(Context context, Intent intent) { String action = ""; // by default, the action is ACTION_START. This is assumed on device boot. if (intent != null && !TextUtils.isEmpty(intent.getAction())) { action = intent.getAction();//from ww w .ja va 2 s . c o m Timber.d("Sync scheduler request: %s", action); } Intent syncIntent = new Intent(context, SyncBroadcastReceiver.class); PendingIntent pendingSyncIntent = PendingIntent.getBroadcast(context, SyncConstants.REQUEST_PERIODIC_SYNC, syncIntent, PendingIntent.FLAG_UPDATE_CURRENT); // PendingIntent.FLAG_CANCEL_CURRENT, FLAG_UPDATE_CURRENT AlarmManager alarmManager = getAlarmManager(context); // Cancel existing heartbeat. if (action.equals(ACTION_STOP)) { Timber.d("Stopping synchronization alarm."); alarmManager.cancel(pendingSyncIntent); return; } startHeartbeat(context, alarmManager, pendingSyncIntent); }
From source file:es.udc.robotcontrol.testapp.comunication.ConectorPlaca.java
@Override public void conectar(Context ctx, Intent intent) throws TransmisionErrorException { Log.i(Constantes.TAG_CONECTOR, "Conectando a [ " + intent.getAction() + " ]. modo - Host"); device = intent.getParcelableExtra(UsbManager.EXTRA_DEVICE); Log.i(Constantes.TAG_CONECTOR, "Conectando a [ " + device.getDeviceName() + " ]. modo - Host"); /* Get the USB manager from the requesting context */ this.manager = (UsbManager) ctx.getSystemService(Context.USB_SERVICE); conectar();//w w w.ja va 2 s.c o m }
From source file:au.id.micolous.frogjump.LoginActivity.java
private boolean resolveIntent(Intent intent) { if (intent.getAction().equals(Intent.ACTION_VIEW)) { final Uri intentUri = intent.getData(); if (intentUri.getHost().endsWith("frjmp.xyz")) { // Known host, figure out our action! List<String> pathSegments = intentUri.getPathSegments(); if (pathSegments.get(0).equalsIgnoreCase("g")) { // Join Group (G) // Parameter 1 is the group number, prefill the box with it. // Make sure it is a number int group_id; try { group_id = Integer.valueOf(pathSegments.get(1)); } catch (NumberFormatException ex) { return false; }/*from w w w . ja v a2s .c o m*/ // Now set the text field txtGroupId.setText(String.format("%1$09d", group_id)); // Make sure futures are set to auto-join auto_join = true; } } } return false; }
From source file:com.github.opengarageapp.GarageService.java
@Override protected void onHandleIntent(Intent intent) { String host = application.getServerHost(); int port = application.getServerPort(); Intent broadcast = new Intent(intent.getAction()); try {//from ww w. ja va 2s. c om String protocol = SECURE ? "https" : "http"; String baseString = protocol + "://" + host + ":" + port + "/openGarageServer/Garage/"; HttpsURLConnection urlConnection = getRequestFromIntent(baseString, intent); int responseCode = urlConnection.getResponseCode(); application.getAuthenticator().setSuccessfulConnectionMade(); //getResponseCode or getInputStream signals to actually make the request if (responseCode == HttpStatus.SC_OK) { String responseBody = convertStreamToString(urlConnection.getInputStream()); urlConnection.getInputStream().close(); broadcast.putExtra(EXTRA_HTTP_RESPONSE_TEXT, responseBody); } else { broadcast.putExtra(EXTRA_HTTP_RESPONSE_TEXT, ""); } Log.i(GarageService.class.getName(), "Response Code: " + responseCode); broadcast.putExtra(EXTRA_HTTP_RESPONSE_CODE, responseCode); } catch (Exception e) { Log.e(getClass().getName(), "Exception", e); broadcast.putExtra(EXTRA_HTTP_RESPONSE_CODE, -1); broadcast.putExtra(EXTRA_HTTP_RESPONSE_TEXT, e.getMessage()); } finally { sendBroadcast(broadcast); } }
From source file:com.google.samples.apps.iosched.service.FeedbackListenerService.java
public int onStartCommand(Intent intent, int flags, int startId) { if (null != intent) { String action = intent.getAction(); if (SessionAlarmService.ACTION_NOTIFICATION_DISMISSAL.equals(action)) { String sessionId = intent.getStringExtra(SessionAlarmService.KEY_SESSION_ID); LOGD(TAG, "onStartCommand(): Action = ACTION_NOTIFICATION_DISMISSAL Session: " + sessionId); dismissWearableNotification(sessionId); }/*w w w . j a v a2s .c om*/ } return Service.START_NOT_STICKY; }
From source file:edu.mit.media.funf.funftowotk.MainPipeline.java
@Override protected void onHandleIntent(Intent intent) { if (ACTION_RUN_ONCE.equals(intent.getAction())) { String probeName = intent.getStringExtra(RUN_ONCE_PROBE_NAME); runProbeOnceNow(probeName);//from w w w .j a v a 2s. c om } else { String action = intent.getAction(); if (super.ACTION_UPLOAD_DATA.equals(action)) { //disable real-time upload if need be } super.onHandleIntent(intent); } }
From source file:be.benvd.mvforandroid.data.MVDataService.java
/** * Does the actual work.// ww w.ja va2s .c om */ @Override protected void doWakefulWork(Intent intent) { String action = intent.getAction(); try { if (action.equals(UPDATE_CREDIT)) { updateCredit(); } else if (action.equals(UPDATE_TOPUPS)) { updateTopups(); } else if (action.equals(UPDATE_USAGE)) { updateUsage(intent.getLongExtra(UPDATE_USAGE_STARTTIME, 0), intent.getLongExtra(UPDATE_USAGE_ENDTIME, 0)); } else if (action.equals(UPDATE_ALL)) { if (prefs.getBoolean("auto_credit", true)) updateCredit(); if (prefs.getBoolean("auto_usage", false)) updateUsage(); if (prefs.getBoolean("auto_topups", false)) updateTopups(); scheduleNextUpdate(); } else if (action.equals(STOP_SERVICE)) { Log.v(MVDataService.class.getSimpleName(), "Update canceled"); alarm.cancel(wakefulWorkIntent); stopSelf(); } else if (action.equals(SCHEDULE_SERVICE)) { scheduleNextUpdate(); } } catch (IOException e) { exceptionBroadcast.putExtra(EXCEPTION, e); sendBroadcast(exceptionBroadcast); } catch (JSONException e) { exceptionBroadcast.putExtra(EXCEPTION, e); sendBroadcast(exceptionBroadcast); } }
From source file:eu.thecoder4.gpl.pleftdroid.HandleLinksActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); TextView tv = new TextView(this); tv.setText("Verifying Link..."); setContentView(tv);/* w ww . j ava2 s . c o m*/ Intent intent = getIntent(); if (intent.getAction().equals("android.intent.action.VIEW")) { try { Uri uri = getIntent().getData(); theurl = uri.toString(); } catch (Exception e) { Toast.makeText(this, R.string.toast_couldnotopenurl, Toast.LENGTH_LONG).show(); } } else if (Intent.ACTION_SEND.equals(intent.getAction())) { Bundle extras = intent.getExtras(); theurl = extras.getCharSequence(Intent.EXTRA_TEXT).toString(); } else { theurl = ""; } //Toast.makeText(this, "The URL = "+theurl, Toast.LENGTH_LONG).show(); // Parse the URL // VERIFICATION: verify?id=&u=&p= // INVITATION: a?id=&u=&p= if (theurl.indexOf("?") < 0 && theurl.indexOf("/verify?") < 0 && theurl.indexOf("/a?") < 0) { Toast.makeText(this, R.string.toast_linknotsupp, Toast.LENGTH_LONG).show(); finish(); } else { Map<String, String> arr = PleftBroker.getParamsFromURL(theurl); pserver = arr.get("pserver"); if (arr.get("id") != null) { aid = Integer.parseInt(arr.get("id")); } else { aid = 0; } vcode = arr.get("p"); user = arr.get("u"); if (aid == 0 || vcode == null || user == null) { Toast.makeText(this, R.string.toast_shlinknotvalid, Toast.LENGTH_LONG).show(); finish(); } else { // we have a valid Link handleLnk = new Runnable() { @Override public void run() { handleLink(); } }; Thread thread = new Thread(null, handleLnk, "Handlethrd"); thread.start(); } // End - if Link is Valid } }
From source file:com.saarang.samples.apps.iosched.service.FeedbackListenerService.java
public int onStartCommand(Intent intent, int flags, int startId) { if (null != intent) { String action = intent.getAction(); if (SessionAlarmService.ACTION_NOTIFICATION_DISMISSAL.equals(action)) { String sessionId = intent.getStringExtra(SessionAlarmService.KEY_SESSION_ID); LogUtils.LOGD(TAG,/* w ww .jav a 2s . co m*/ "onStartCommand(): Action = ACTION_NOTIFICATION_DISMISSAL Session: " + sessionId); dismissWearableNotification(sessionId); } } return Service.START_NOT_STICKY; }
From source file:jp.co.brilliantservice.android.writertdtext.HomeActivity.java
@Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); String action = intent.getAction(); if (TextUtils.isEmpty(action)) return;/*from ww w. j a v a 2 s . c o m*/ if (!action.equals(NfcAdapter.ACTION_TECH_DISCOVERED)) return; // NdefMessage? String languageCode = "en"; String text = String.format("Hello, World.(%s)", DATE_FORMAT.format(System.currentTimeMillis())); NdefMessage message = createTextMessage(text, languageCode); // ?????????? Tag tag = (Tag) intent.getParcelableExtra(NfcAdapter.EXTRA_TAG); List<String> techList = Arrays.asList(tag.getTechList()); if (techList.contains(Ndef.class.getName())) { Ndef ndef = Ndef.get(tag); writeNdefToNdefTag(ndef, message); Toast.makeText(getApplicationContext(), "wrote NDEF to NDEF tag", Toast.LENGTH_SHORT).show(); } else if (techList.contains(NdefFormatable.class.getName())) { NdefFormatable ndef = NdefFormatable.get(tag); writeNdefToNdefFormatable(ndef, message); Toast.makeText(getApplicationContext(), "wrote NDEF to NDEFFormatable tag", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(getApplicationContext(), "NDEF Not Supported", Toast.LENGTH_SHORT).show(); } }