List of usage examples for android.app Activity RESULT_FIRST_USER
int RESULT_FIRST_USER
To view the source code for android.app Activity RESULT_FIRST_USER.
Click Source Link
From source file:org.kde.kdeconnect.Plugins.SharePlugin.SendFileActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mDeviceId = getIntent().getStringExtra("deviceId"); Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("*/*"); intent.addCategory(Intent.CATEGORY_OPENABLE); try {// ww w .j a v a 2 s .com startActivityForResult(Intent.createChooser(intent, getString(R.string.send_files)), Activity.RESULT_FIRST_USER); } catch (android.content.ActivityNotFoundException ex) { Toast.makeText(this, R.string.no_file_browser, Toast.LENGTH_SHORT).show(); finish(); } }
From source file:org.kde.kdeconnect.Plugins.SharePlugin.SendFileActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case Activity.RESULT_FIRST_USER: if (resultCode == RESULT_OK) { final Uri uri = data.getData(); Log.e("SendFileActivity", "File Uri: " + uri.toString()); BackgroundService.RunCommand(this, new BackgroundService.InstanceCallback() { @Override//from w ww. j ava 2 s . co m public void onServiceStart(BackgroundService service) { Device device = service.getDevice(mDeviceId); if (device == null) { finish(); } ArrayList<Uri> uris = new ArrayList<>(); uris.add(uri); SharePlugin.queuedSendUriList(getApplicationContext(), device, uris); } }); } finish(); break; default: super.onActivityResult(requestCode, resultCode, data); } }
From source file:mx.itesm.logistics.crew_tracking.activity.VehicleListActivity.java
@Override public boolean onOptionsItemSelected(MenuItem menuItem) { switch (menuItem.getItemId()) { case R.id.vehicle_menu_item_skip: setResult(Activity.RESULT_FIRST_USER); finish();// w w w .j a v a 2 s.c o m return true; default: return super.onOptionsItemSelected(menuItem); } }
From source file:com.semfapp.adamdilger.semf.Take5F4.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (data == null) { Log.d(TAG, "onActivityResult: data == null"); return;//from ww w. j av a 2s . c o m } if (resultCode == Activity.RESULT_OK) { int pos = data.getIntExtra(Take5RiskElementActivity.POS_EXTRA, -1); String one = data.getStringExtra(Take5RiskElementActivity.ONE_EXTRA); String rating = data.getStringExtra(Take5RiskElementActivity.RATING_EXTRA); String two = data.getStringExtra(Take5RiskElementActivity.TWO_EXTRA); String imagePath = data.getStringExtra(Take5RiskElementActivity.IMAGE_PATH_EXTRA); Take5RiskElement element; if (pos == -1) { //new item element = new Take5RiskElement(one, two, Take5RiskElement.Rating.NA); if (rating != null) { if (!rating.equals("")) { element.mRating = Take5RiskElement.Rating.valueOf(rating); } } mRiskElements.add(element); } else { //editing item element = mRiskElements.get(pos); element.set(one, two, Take5RiskElement.Rating.valueOf(rating)); } element.imagePath = imagePath; } else if (resultCode == Activity.RESULT_FIRST_USER) { int pos = data.getIntExtra(Take5RiskElementActivity.POS_EXTRA, -1); Log.d(TAG, "onActivityResult: Deleting" + String.format("pos: %d", pos)); //pos == -1 if item has not been added yet //therefore just discard it if (pos != -1) { mRiskElements.remove(pos); } } //notify adapter of data change ((ListAdapter) getListAdapter()).notifyDataSetChanged(); }
From source file:nl.mpcjanssen.simpletask.Simpletask.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); switch (requestCode) { case REQUEST_SHARE_PARTS: if (resultCode != Activity.RESULT_CANCELED) { int flags = resultCode - Activity.RESULT_FIRST_USER; shareTodoList(flags);// ww w . j ava2s .com } break; } }
From source file:org.fdroid.fdroid.installer.DefaultInstallerActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case REQUEST_CODE_INSTALL: /**/*from w ww . j a va2 s . co m*/ * resultCode is always 0 on Android < 4.0. See * com.android.packageinstaller.PackageInstallerActivity: setResult is * never executed on Androids < 4.0 */ if (Build.VERSION.SDK_INT < 14) { installer.sendBroadcastInstall(downloadUri, Installer.ACTION_INSTALL_COMPLETE); break; } switch (resultCode) { case Activity.RESULT_OK: installer.sendBroadcastInstall(downloadUri, Installer.ACTION_INSTALL_COMPLETE); break; case Activity.RESULT_CANCELED: installer.sendBroadcastInstall(downloadUri, Installer.ACTION_INSTALL_INTERRUPTED); break; case Activity.RESULT_FIRST_USER: default: // AOSP returns Activity.RESULT_FIRST_USER on error installer.sendBroadcastInstall(downloadUri, Installer.ACTION_INSTALL_INTERRUPTED, getString(R.string.install_error_unknown)); break; } break; case REQUEST_CODE_UNINSTALL: // resultCode is always 0 on Android < 4.0. if (Build.VERSION.SDK_INT < 14) { installer.sendBroadcastUninstall(uninstallPackageName, Installer.ACTION_UNINSTALL_COMPLETE); break; } switch (resultCode) { case Activity.RESULT_OK: installer.sendBroadcastUninstall(uninstallPackageName, Installer.ACTION_UNINSTALL_COMPLETE); break; case Activity.RESULT_CANCELED: installer.sendBroadcastUninstall(uninstallPackageName, Installer.ACTION_UNINSTALL_INTERRUPTED); break; case Activity.RESULT_FIRST_USER: default: // AOSP UninstallAppProgress returns RESULT_FIRST_USER on error installer.sendBroadcastUninstall(uninstallPackageName, Installer.ACTION_UNINSTALL_INTERRUPTED, getString(R.string.uninstall_error_unknown)); break; } break; default: throw new RuntimeException("Invalid request code!"); } // after doing the broadcasts, finish this transparent wrapper activity finish(); }
From source file:com.wheelly.activity.FilterDialog.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == PERIOD_REQUEST) { if (resultCode == Activity.RESULT_FIRST_USER) { filter.remove(F.PERIOD);//from ww w. j a v a 2 s .co m c.period.setText(R.string.no_filter); } else if (resultCode == Activity.RESULT_OK) { filter.put(F.PERIOD, data.getStringExtra(F.PERIOD)); updatePeriodFromFilter(filter); } } }
From source file:org.opensilk.video.tv.ui.playback.PlaybackControlsFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); PlaybackActivityComponent activityComponent = DaggerService.getDaggerComponent(getActivity()); mComponent = activityComponent//from ww w. ja v a 2 s.c o m .newPlaybackControlsComponent(new PlaybackControlsModule(getActivity(), this)); mComponent.inject(this); setBackgroundType(BG_NONE); //init mediaController mMediaController = getActivity().getMediaController(); mMediaController.registerCallback(mMediaControllerCallback); //init primary adapter ClassPresenterSelector presenterSelector = new ClassPresenterSelector(); mAdapter = new SparseArrayObjectAdapter(presenterSelector); //init controls row mControlsRowGlue = new PlaybackControlsGlue(getContext(), this, mMediaController); MediaMetadata mediaMetadata = mMediaController.getMetadata(); if (mediaMetadata != null) { mControlsRowGlue.onMetadataChanged(mediaMetadata); } PlaybackState playbackState = mMediaController.getPlaybackState(); if (playbackState != null) { mControlsRowGlue.onStateChanged(playbackState); } PlaybackControlsRowPresenter controlsRowPresenter = mControlsRowGlue.createControlsRowAndPresenter(); PlaybackControlsRow controlsRow = mControlsRowGlue.getControlsRow(); // SparseArrayObjectAdapter secondaryActionsAdapter = // new SparseArrayObjectAdapter(new ControlButtonPresenterSelector()); // secondaryActionsAdapter.set(5, new PlaybackControlsRow.ClosedCaptioningAction(getContext())); // controlsRow.setSecondaryActionsAdapter(secondaryActionsAdapter); presenterSelector.addClassPresenter(PlaybackControlsRow.class, controlsRowPresenter); mAdapter.set(CONTROLS_ROW, controlsRow); //init overview row mOverviewRow = new PlaybackOverviewRow(new HeaderItem("Overview")); PlaybackOverviewRowPresenter overviewRowPresenter = new PlaybackOverviewRowPresenter(); if (playbackState != null) { updateOverview(playbackState.getActiveQueueItemId()); } presenterSelector.addClassPresenter(PlaybackOverviewRow.class, overviewRowPresenter); mAdapter.set(OVERVIEW_ROW, mOverviewRow); Subscription overviewSub = mOverviewObservable.subscribe(info -> { mOverviewRow.setItem(info); }, e -> { Timber.w("videoDescription"); }); mSubscriptions.add(overviewSub); //init queue row QueueAdapter queueRowAdapter = new QueueAdapter(); List<MediaSession.QueueItem> queue = mMediaController.getQueue(); if (queue != null) { queueRowAdapter.swap(queue); } CharSequence queueTitle = mMediaController.getQueueTitle(); if (StringUtils.isEmpty(queueTitle)) { queueTitle = "Queue"; } mQueueRow = new ListRow(new HeaderItem(queueTitle.toString()), queueRowAdapter); presenterSelector.addClassPresenter(ListRow.class, new ListRowPresenter()); mAdapter.set(QUEUE_ROW, mQueueRow); //init subtitle row SubtitleAdapter subtitleAdapter = new SubtitleAdapter(); mSubtitleRow = new ListRow(new HeaderItem("Subtitles"), subtitleAdapter); //not adding yet //set adapter setAdapter(mAdapter); setOnItemViewClickedListener(new ItemClickListener()); //on new items update the activity result Subscription resultSub = mMediaItemObservable.subscribe(item -> { Activity activity = getActivity(); if (activity != null) { Intent result = new Intent().putExtra(DetailsActivity.MEDIA_ITEM, item); activity.setResult(Activity.RESULT_FIRST_USER + 12, result); } }, e -> { Timber.w(e, "setResult()"); }); mSubscriptions.add(resultSub); }
From source file:us.rader.wyfy.SavedRowsFragment.java
/** * Call {@link Activity#setResult(int, Intent)} and * {@link Activity#finish()}/*from w ww . j ava 2s . co m*/ * * @param row * the data to pass back to the <code>Activity</code> that started * this one */ private void returnRowToCaller(Map<String, String> row) { FragmentActivity activity = getActivity(); if (row == null) { activity.setResult(Activity.RESULT_FIRST_USER); activity.finish(); return; } StringBuilder buffer = new StringBuilder("result"); //$NON-NLS-1$ buffer.append('?'); buffer.append(Uri.encode(WiFiSettingsContract.WifiSettingsEntry.COLUMN_NAME_HIDDEN)); buffer.append('='); buffer.append(Uri.encode(row.get(WiFiSettingsContract.WifiSettingsEntry.COLUMN_NAME_HIDDEN))); buffer.append('&'); buffer.append(Uri.encode(WiFiSettingsContract.WifiSettingsEntry.COLUMN_NAME_PASSWORD)); buffer.append('='); buffer.append(Uri.encode(row.get(WiFiSettingsContract.WifiSettingsEntry.COLUMN_NAME_PASSWORD))); buffer.append('&'); buffer.append(Uri.encode(WiFiSettingsContract.WifiSettingsEntry.COLUMN_NAME_SECURITY)); buffer.append('='); buffer.append(Uri.encode(row.get(WiFiSettingsContract.WifiSettingsEntry.COLUMN_NAME_SECURITY))); buffer.append('&'); buffer.append(Uri.encode(WiFiSettingsContract.WifiSettingsEntry.COLUMN_NAME_SSID)); buffer.append('='); buffer.append(Uri.encode(row.get(WiFiSettingsContract.WifiSettingsEntry.COLUMN_NAME_SSID))); Uri uri = Uri.parse(buffer.toString()); Intent intent = new Intent(); intent.setData(uri); activity.setResult(Activity.RESULT_OK, intent); activity.finish(); }
From source file:com.facebook.android.friendsmash.HomeFragment.java
public void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == REAUTH_ACTIVITY_CODE) { // This ensures a session state change is recorded so that the tokenUpdated() callback is triggered // to attempt a post if the write permissions have been granted Log.i(FriendSmashApplication.TAG, "Reauthorized with publish permissions."); Session.getActiveSession().onActivityResult(getActivity(), requestCode, resultCode, data); } else if (resultCode == Activity.RESULT_OK && data != null) { // Finished a game Bundle bundle = data.getExtras(); application.setScore(bundle.getInt("score")); updateYouScoredTextView();/*w ww .ja v a2 s . c o m*/ updateButtonVisibility(); completeGameOver(1500); } else if (resultCode == Activity.RESULT_FIRST_USER && data != null) { // Came from the ScoreboardFragment, so start a game with the specific user who has been clicked Intent i = new Intent(getActivity(), GameActivity.class); Bundle bundle = new Bundle(); bundle.putString("user_id", data.getStringExtra("user_id")); i.putExtras(bundle); startActivityForResult(i, 0); } else if (resultCode == Activity.RESULT_CANCELED && data != null) { Bundle bundle = data.getExtras(); ((HomeActivity) getActivity()).showError(bundle.getString("error"), false); } else if (resultCode == Activity.RESULT_CANCELED && ((FriendSmashApplication) getActivity().getApplication()) .getGameFragmentFBRequestError() != null) { ((HomeActivity) getActivity()).handleError( ((FriendSmashApplication) getActivity().getApplication()).getGameFragmentFBRequestError(), false); ((FriendSmashApplication) getActivity().getApplication()).setGameFragmentFBRequestError(null); } }