logo
down
shadow

How can I exactly know what finish() does relate to setResult() in android?


How can I exactly know what finish() does relate to setResult() in android?

By : Raymond Veldhuizen
Date : October 28 2020, 07:41 AM
Any of those help If you want to return a result, you have to call setResult. Otherwise how would the Activity know what to return. Generally you don't call it right before calling finish- you call it whenever a value is generated. Then calling finish will automatically return the last value set.
For example- if I have an image picker activity, every time an image was clicked I'd set the result (or I'd set it once at the start and update its values each click). Then when finish was called normally, it would know what result to return.
code :


Share : facebook icon twitter icon
What is the iOS equivalent of Android's startActivityForResult/setResult?

What is the iOS equivalent of Android's startActivityForResult/setResult?


By : user3465991
Date : March 29 2020, 07:55 AM
Any of those help I am an Android programmer learning iOS. I have a swift view1 that calls an objective C view2. I am looking to return a String from view2 back to view 1. , ViewController2.h - Objective-C
code :
@protocol ViewController2Delegate <NSObject>
- (void)sendStringBack:(NSString *)aString;
@end 

@interface ViewController2 : UIViewController
@property (nonatomic, weak) id<ViewController2Delegate> delegate;
@end
// When you want to send the string back and dismiss the view:
[self.delegate sendStringBack:theStringToSendBack];
@objc class ViewController1: UIViewController, ViewController2Delegate {
     override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        let viewContr = segue.destinationViewController as! ViewController2
        viewContr.delegate = self
    }

    func sendStringBack(aString: String) {
        let aVariable = aString
        // do something with the string

        // dismiss the view if you presented it modally
        self.dismissViewController(self, animated: true, completion: nil)

        // OR
        // dismiss the view if you presented it with show/push
        self.navigationController?.popViewControllerAnimated(true)
    }
}
setResult(int, intent) not working in Android

setResult(int, intent) not working in Android


By : user3736017
Date : March 29 2020, 07:55 AM
I hope this helps . BroadcastReceiver has its setResult method, which takes three parameters, not two, and you probably want to use setResult from the class Activity. Reference it like:
code :
ActivityName.this.setResult(RESULT_OK, data);
ListView Adapter setResult() and Finish() error

ListView Adapter setResult() and Finish() error


By : Lorenzo Rizza
Date : March 29 2020, 07:55 AM
should help you out you must hold an reference to your activity that created the adapter then set result to that. the thing you are doing is setting the result of OnClickListener object !!
add an Activity object to your adapter constructor and save it in a local variable in adapter and call it act then call the setResult() of the activtiy like below:
code :
view.setOnClickListener(new OnClickListener() {

    @Override
    public void onClick(View arg0) {
        SharedPreferences prefernces = mContext.getSharedPreferences("MyKey111", Context.MODE_PRIVATE);
        SharedPreferences.Editor editor1 = prefernces.edit();
        editor1.putString("Custname",customerpopulationlist.get(position).getName());
        editor1.putString("let_id", customerpopulationlist.get(position).getLetId());
        editor1.commit();

        Intent intentMessage = new Intent();

        // put the message in Intent
        intentMessage.putExtra("MESSAGE", "hello");
        intentMessage.putExtra("selected_refer", customerpopulationlist.get(position).getLetId());

        //THESE TWO LINES NEED TO BE CHANGED
        act.setResult(RESULT_OK, intentMessage);
        act.finish();

    }
});
Android: setResult not working

Android: setResult not working


By : pranav shinde
Date : March 29 2020, 07:55 AM
it should still fix some issue Scenario: I have a MainActivity.java, OtherPageForFragments.java and a fragment which is on OtherPageForFragments.java
Android setResult does not match onActivityResult

Android setResult does not match onActivityResult


By : bala ji
Date : March 29 2020, 07:55 AM
hop of those help? I figured it out. According to this post and the Android documentation, the setResult(int, Intent) method must be called before the activity is finished (i.e. before calling onPause(), onStop(), or onDestroy. I tried putting it in onBackPressed() but didn't work initially because I called the super.onBackPressed() in the first line. Finally, this worked:
Related Posts Related Posts :
  • Getting a string value from the strings.xml resource file and set it in an interface class
  • Flutter, sign with both debug keys and release keys on Android
  • will an android service run code from the Xamarin Forms Project even when the app is closed?
  • Change boolean values on listviewitems in firebase
  • Android Studio 3.2.1: mixing versions can lead to runtime crashes when connect firebase
  • FCM migration without losing the old token
  • Change reported Version Number in Fabric Crashlytics
  • lateinit property mMap has not been initialized
  • Android - PWA does not open in standalone mode with service worker
  • Does LeakCanary has callback?
  • How to disable back button after splash screen in React Native
  • Assets Folder Not Including HTML Files In NativeScript Android Build
  • Dagger: What if I *WANT* a new instance every time?
  • How to get mailto working on android chrome?
  • SSO web login in android app with customtabs
  • how to make specific button side curved
  • remove item onlongclick from listview
  • header image alignment coming wrongly in NavigationView android
  • How to add many spaces after the text in TextView
  • how to set "Back Button" , closing activies except main activity in android?
  • Unable to run emulator on Android Studio || Windows 10
  • How can I achieve this requirement using Rx Java
  • How to tilt a Node(or TransformableNode)object downwards in Sceneform(Ar Core)?
  • When to use RTL and LTR?
  • How to create a tab view (category) similar to instagram's explore tab
  • Glide, RecyclerView: Glide returns the same picture over and over again even with different data inputs
  • how to stop open activity while splash screen killed
  • Changing the Color of the Dynamically loaded Buttons onclick
  • Listview: Add arrows as dividers
  • Show confirmation on back/up in Fragment with Navigation Architecture Component
  • How to find the corresponding maven artifact/gradle module of an Android class from the API Docs?
  • ZXing 3.6.0 in portrait mode?
  • Can't use Subversion command line client: svn The path to the Subversion executable is probably wrong android
  • how to set spinner list value first position showing empty
  • When using PersistableBundle in onCreate, it shows me a blank page
  • Failed to resolve Bintray dependency
  • jacoco code coverage not working for Android applications
  • How to change the color of the Android scroll bumper
  • Why run Handler in main Looper thread
  • Android Studio combined chart crashes
  • Setting suggested width and height to a custom view in android
  • How to set input type and format in EditText using kotlin?
  • how to define Android Oncreate optionmenu
  • Exception on orientation change from two-pane mode to one-pane mode
  • How to access members of nested struct and assign them the values read from device tree?
  • How to measure upload progress of a huge String with Retrofit 2?
  • Runtime app localization doesn't work with app bundles
  • How create View and Putting TextView inside it in kotlin
  • how to integrate app action using actions.xml?
  • ConstraintLayout - center TextView in the root but don't override Button
  • Android Studio Text not conforming to layout_margin when I run App on Emulator
  • verifyReleaseResources apk release - react native
  • My app is not visible in share dialog even with intent filters in place
  • How to use cache or local storage?
  • Unhandled Exception in Recycler view xamarin
  • Android Workmanger PeriodicWorkRequest API work only once?
  • Using Touch ID or Face ID without storing user biometrics
  • React Native 3 button and 3 Modal
  • Token Expiration after 1 Hour in Authentication using Retrofit 2 and Logging Interceptor
  • JNI DETECTED ERROR IN APPLICATION: JNI NewGlobalRef called with pending exception java.lang.ClassNotFoundException:
  • shadow
    Privacy Policy - Terms - Contact Us © bighow.org