List of usage examples for android.content Intent getBooleanExtra
public boolean getBooleanExtra(String name, boolean defaultValue)
From source file:com.cyanogenmod.settings.device.LtoDownloadService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { if (mTask != null && mTask.getStatus() != AsyncTask.Status.FINISHED) { if (ALOGV) Log.v(TAG, "LTO download is still active, not starting new download"); return START_REDELIVER_INTENT; }/* w ww . j av a 2s .co m*/ boolean forceDownload = intent.getBooleanExtra(EXTRA_FORCE_DOWNLOAD, false); if (!shouldDownload(forceDownload)) { Log.d(TAG, "Service started, but shouldn't download ... stopping"); stopSelf(); return START_NOT_STICKY; } SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); String type = prefs.getString(KEY_FILE_TYPE, FILE_TYPE_DEFAULT); String uri = String.format(LTO_SOURCE_URI_PATTERN, type); mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); mTask = new LtoDownloadTask(uri, LTO_DESTINATION_FILE); mTask.execute(); return START_REDELIVER_INTENT; }
From source file:com.amaze.filemanager.asynchronous.services.CopyService.java
@Override public int onStartCommand(Intent intent, int flags, final int startId) { Bundle b = new Bundle(); isRootExplorer = intent.getBooleanExtra(TAG_IS_ROOT_EXPLORER, false); ArrayList<HybridFileParcelable> files = intent.getParcelableArrayListExtra(TAG_COPY_SOURCES); String targetPath = intent.getStringExtra(TAG_COPY_TARGET); int mode = intent.getIntExtra(TAG_COPY_OPEN_MODE, OpenMode.UNKNOWN.ordinal()); final boolean move = intent.getBooleanExtra(TAG_COPY_MOVE, false); sharedPreferences = PreferenceManager.getDefaultSharedPreferences(c); accentColor = ((AppConfig) getApplication()).getUtilsProvider().getColorPreference() .getCurrentUserColorPreferences(this, sharedPreferences).accent; mNotifyManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); b.putInt(TAG_COPY_START_ID, startId); Intent notificationIntent = new Intent(this, MainActivity.class); notificationIntent.setAction(Intent.ACTION_MAIN); notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); notificationIntent.putExtra(MainActivity.KEY_INTENT_PROCESS_VIEWER, true); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); customSmallContentViews = new RemoteViews(getPackageName(), R.layout.notification_service_small); customBigContentViews = new RemoteViews(getPackageName(), R.layout.notification_service_big); Intent stopIntent = new Intent(TAG_BROADCAST_COPY_CANCEL); PendingIntent stopPendingIntent = PendingIntent.getBroadcast(c, 1234, stopIntent, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Action action = new NotificationCompat.Action(R.drawable.ic_content_copy_white_36dp, getString(R.string.stop_ftp), stopPendingIntent); mBuilder = new NotificationCompat.Builder(c, NotificationConstants.CHANNEL_NORMAL_ID) .setContentIntent(pendingIntent).setSmallIcon(R.drawable.ic_content_copy_white_36dp) .setCustomContentView(customSmallContentViews).setCustomBigContentView(customBigContentViews) .setCustomHeadsUpContentView(customSmallContentViews) .setStyle(new NotificationCompat.DecoratedCustomViewStyle()).addAction(action).setOngoing(true) .setColor(accentColor);//w w w.j a v a2s.com // set default notification views text NotificationConstants.setMetadata(c, mBuilder, NotificationConstants.TYPE_NORMAL); startForeground(NotificationConstants.COPY_ID, mBuilder.build()); initNotificationViews(); b.putBoolean(TAG_COPY_MOVE, move); b.putString(TAG_COPY_TARGET, targetPath); b.putInt(TAG_COPY_OPEN_MODE, mode); b.putParcelableArrayList(TAG_COPY_SOURCES, files); super.onStartCommand(intent, flags, startId); super.progressHalted(); //going async new DoInBackground(isRootExplorer).execute(b); // If we get killed, after returning from here, restart return START_STICKY; }
From source file:dk.ciid.android.infobooth.activities.SubscriptionFinalActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { /* Variables received through Intent */ Intent openActivity = getIntent(); // this is just for example purpose isInDebugMode = openActivity.getBooleanExtra("isInDebugMode", true); // should the app send a welcome sms after subscribing? phoneNum = openActivity.getStringExtra("phoneNum"); // get the phonenumber submitted in the last activity selectedService = openActivity.getIntExtra("selectedService", 1); // array position of selected service in last activity serviceIdItems = openActivity.getStringArrayListExtra("serviceIdItems"); // arraylist of service id's (in database) serviceNameItems = openActivity.getStringArrayListExtra("serviceNameItems"); // arraylist of service names serviceDescItems = openActivity.getStringArrayListExtra("serviceDescItems"); // arraylist of service descriptions voice1 = openActivity.getStringExtra("voice1"); // path to voice file 1 voice2 = openActivity.getStringExtra("voice2"); // path to voice file 2 voice3 = openActivity.getStringExtra("voice3"); // path to voice file 3 voice4 = openActivity.getStringExtra("voice4"); // path to voice file 4 voice5 = openActivity.getStringExtra("voice5"); // path to voice file 5 voice6 = openActivity.getStringExtra("voice6"); // path to voice file 6 /* Variables received through Intent */ // TODO Auto-generated method stub super.onCreate(savedInstanceState); /* ARDUINO COMMUNICATION STUFF ********************************************/ // a reference to the USB system service is obtained so that you can call its methods later on mUsbManager = UsbManager.getInstance(this); mPermissionIntent = PendingIntent.getBroadcast(this, 0, new Intent(ACTION_USB_PERMISSION), 0); IntentFilter filter = new IntentFilter(ACTION_USB_PERMISSION); filter.addAction(UsbManager.ACTION_USB_ACCESSORY_DETACHED); registerReceiver(mUsbReceiver, filter); if (getLastNonConfigurationInstance() != null) { mAccessory = (UsbAccessory) getLastNonConfigurationInstance(); openAccessory(mAccessory);//from w w w .ja v a 2 s . c o m } /* ARDUINO COMMUNICATION STUFF ********************************************/ gestureScanner = new GestureDetector(this); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.activity_subscription_final); if (!isInDebugMode) { try { //SmsManager smsManager = SmsManager.getDefault(); //smsManager.sendTextMessage(phoneNumber, null, SMSMessage, null, null); Toast.makeText(getApplicationContext(), "Thanks for subscribing!", Toast.LENGTH_SHORT).show(); } catch (Exception e) { Toast.makeText(getApplicationContext(), "SMS failed, please try again later!", Toast.LENGTH_SHORT) .show(); e.printStackTrace(); } } else { Toast.makeText(getApplicationContext(), "Debug mode - no SMS sent to save money :)", Toast.LENGTH_SHORT) .show(); } // Set up sound playback initMediaPlayer(); }
From source file:com.finchuk.clock2.timers.ui.TimersFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode != Activity.RESULT_OK || data == null) return;/*from www. j a v a 2s .co m*/ // TODO: From EditTimerActivity, pass back the Timer as a parcelable and // retrieve it here directly. int hour = data.getIntExtra(EditTimerActivity.EXTRA_HOUR, -1); int minute = data.getIntExtra(EditTimerActivity.EXTRA_MINUTE, -1); int second = data.getIntExtra(EditTimerActivity.EXTRA_SECOND, -1); String label = data.getStringExtra(EditTimerActivity.EXTRA_LABEL); boolean startTimer = data.getBooleanExtra(EditTimerActivity.EXTRA_START_TIMER, false); // TODO: Timer's group? Timer t = Timer.createWithLabel(hour, minute, second, label); if (startTimer) { t.start(); } mAsyncTimersTableUpdateHandler.asyncInsert(t); }
From source file:com.example.android.todolist.AddTaskActivity.java
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_add_task); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN); toolbar = (Toolbar) findViewById(R.id.archive_toolbar); add_btn = (FloatingActionButton) findViewById(R.id.addButton); delete_btn = (FloatingActionButton) findViewById(R.id.fab_delete); picked_color = (FloatingActionButton) findViewById(R.id.pick_color); formated_time = (TextView) findViewById(R.id.pickedTime); edt_title = (EditText) findViewById(R.id.editTextTaskDescription); edt_description = (EditText) findViewById(R.id.TaskDescription); choosenTime = (TextView) findViewById(R.id.pickedTime); contentValues = new ContentValues(); delete_btn.setVisibility(View.INVISIBLE); Intent intent = getIntent(); mCurrentUri = intent.getData();/*from w ww. j a v a 2 s .c om*/ isFromArchive = intent.getBooleanExtra("FROM_ARCHIVE", false); // /tasks/1 // /tasks if (mCurrentUri == null) { // add a new task setTitle("add task"); // Toast.makeText(AddTaskActivity.this, "" + mCurrentUri, Toast.LENGTH_LONG).show(); add_btn.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_send)); } else if (isFromArchive) { // add task from archive add_btn.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_send)); getSupportLoaderManager().initLoader(1, null, this); // archive } else { setTitle("update task"); // update task add_btn.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_done_black_24dp)); delete_btn.setVisibility(View.VISIBLE); int row = Integer.valueOf(mCurrentUri.getLastPathSegment()); String match = TaskContract.TaskEntry.CONTENT_URI.getPath() + "/" + row; if (mCurrentUri.getPath().equals(match)) { isTaskUri = true; getSupportLoaderManager().initLoader(0, null, this); } /* else { getSupportLoaderManager().initLoader(1, null, this); }*/ } picked_color.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { new SpectrumDialog.Builder(AddTaskActivity.this).setColors(R.array.color_array) // .setSelectedColorRes(R.color.md_blue_500) .setDismissOnColorSelected(false) // .setOutlineWidth(2) .setOnColorSelectedListener(new SpectrumDialog.OnColorSelectedListener() { @Override public void onColorSelected(boolean positiveResult, @ColorInt int color) { if (positiveResult) { isColorPicked = true; color_posiotion = color; // Toast.makeText(getApplicationContext(), "" + color, Toast.LENGTH_LONG).show(); // Toast.makeText(AddTaskActivity.this, "Color selected: #" + Integer.toHexString(color).toUpperCase(), Toast.LENGTH_SHORT).show(); } else { Toast.makeText(AddTaskActivity.this, "No color selected", Toast.LENGTH_SHORT) .show(); } } }).build().show(getSupportFragmentManager(), "hi"); } }); fabTime = (FloatingActionButton) findViewById(R.id.time_picked); fabTime.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Calendar now = Calendar.getInstance(); DatePickerDialog dpd = DatePickerDialog.newInstance(AddTaskActivity.this, now.get(Calendar.YEAR), now.get(Calendar.MONTH), now.get(Calendar.DAY_OF_MONTH)); dpd.show(getFragmentManager(), "Datepickerdialog"); dpd.setVersion(DatePickerDialog.Version.VERSION_1); dpd.setThemeDark(false); } }); add_btn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (mCurrentUri == null || isFromArchive) { onClickAddTask(); } else { updateTask(); } } }); delete_btn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { // notify app widget to be updated sendBroadcast(new Intent("ACTION_DATA_UPDATED")); String stringId = Integer.toString(id); Uri uri = TaskContract.TaskEntry.CONTENT_URI; uri = uri.buildUpon().appendPath(stringId).build(); getContentResolver().delete(uri, null, null); finish(); } }); }
From source file:com.otaupdater.OTAUpdaterActivity.java
private boolean handleNotifAction(Intent intent) { String action = intent.getAction(); if (ROM_NOTIF_ACTION.equals(action)) { RomInfo.FACTORY.clearUpdateNotif(this); bar.setSelectedNavigationItem(romTabIdx); if (intent.getBooleanExtra(EXTRA_FLAG_DOWNLOAD_DIALOG, false)) { DownloadBarFragment.showDownloadingDialog(this, cfg.getRomDownloadID(), this); } else {//from w w w. j a v a 2 s. com RomInfo info = RomInfo.FACTORY.fromIntent(intent); if (info == null) info = cfg.getStoredRomUpdate(); if (info != null) info.showUpdateDialog(this, this); } } else if (KERNEL_NOTIF_ACTION.equals(action)) { KernelInfo.FACTORY.clearUpdateNotif(this); bar.setSelectedNavigationItem(kernelTabIdx); if (intent.getBooleanExtra(EXTRA_FLAG_DOWNLOAD_DIALOG, false)) { DownloadBarFragment.showDownloadingDialog(this, cfg.getKernelDownloadID(), this); } else { KernelInfo info = KernelInfo.FACTORY.fromIntent(intent); if (info == null) info = cfg.getStoredKernelUpdate(); if (info != null) info.showUpdateDialog(this, this); } } else { return false; } return true; }
From source file:com.android.calendar.event.EditEventActivity.java
private EventInfo getEventInfoFromIntent(Bundle icicle) { EventInfo info = new EventInfo(); long eventId = -1; Intent intent = getIntent(); Uri data = intent.getData();//from w w w. ja v a2 s. c om if (data != null) { try { eventId = Long.parseLong(data.getLastPathSegment()); } catch (NumberFormatException e) { if (DEBUG) { Log.d(TAG, "Create new event"); } } } else if (icicle != null && icicle.containsKey(BUNDLE_KEY_EVENT_ID)) { eventId = icicle.getLong(BUNDLE_KEY_EVENT_ID); } boolean allDay = intent.getBooleanExtra(EXTRA_EVENT_ALL_DAY, false); long begin = intent.getLongExtra(EXTRA_EVENT_BEGIN_TIME, -1); long end = intent.getLongExtra(EXTRA_EVENT_END_TIME, -1); if (end != -1) { info.endTime = new Time(); if (allDay) { info.endTime.timezone = Time.TIMEZONE_UTC; } info.endTime.set(end); } if (begin != -1) { info.startTime = new Time(); if (allDay) { info.startTime.timezone = Time.TIMEZONE_UTC; } info.startTime.set(begin); } info.id = eventId; info.eventTitle = intent.getStringExtra(Events.TITLE); info.calendarId = intent.getLongExtra(Events.CALENDAR_ID, -1); if (allDay) { info.extraLong = CalendarController.EXTRA_CREATE_ALL_DAY; } else { info.extraLong = 0; } return info; }
From source file:com.amazonaws.youruserpools.UserActivity.java
public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); switch (requestCode) { case 20:// ww w .j a va 2 s .c om // Settings if (resultCode == RESULT_OK) { boolean refresh = data.getBooleanExtra("refresh", true); if (refresh) { showAttributes(); } } break; case 21: // Verify attributes if (resultCode == RESULT_OK) { boolean refresh = data.getBooleanExtra("refresh", true); if (refresh) { showAttributes(); } } break; case 22: // Add attributes if (resultCode == RESULT_OK) { boolean refresh = data.getBooleanExtra("refresh", true); if (refresh) { showAttributes(); } } break; } }
From source file:com.khmelenko.lab.travisclient.activity.MainActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == RESULT_OK) { switch (requestCode) { case AUTH_ACTIVITY_CODE: // clear previous data mFragment.clearData();// ww w . j av a2 s . c om showProgress(); getPresenter().reloadRepos(); break; case REPO_DETAILS_CODE: boolean reloadRequired = data.getBooleanExtra(RepoDetailsActivity.RELOAD_REQUIRED_KEY, false); if (reloadRequired) { showProgress(); getPresenter().reloadRepos(); } break; } } }
From source file:com.amagi82.kerbalspaceapp.MissionPlanner.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == RESULT_OK && data != null) { MissionData result = data.getParcelableExtra("returnItem"); if (data.getBooleanExtra("isNewItem", true)) { missionData.add(result);// www . j av a 2s .co m } else { missionData.set(requestCode, result); } mAdapter.notifyDataSetChanged(); refreshDeltaV(); } if (resultCode == RESULT_CANCELED) { } }