0

I want to make App which is invoked by external App, and allowing it to get some string values in result. I am able to invoke my App, but unable to pass data. So I think something within intent filter is to be modified. Correct me if I am going on wrong track. What value is to be taken for action & category or any other thing from manifest.

    <intent-filter>
            <action android:name="android.intent.action.VIEW"/>
            <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>

Further description @ StartActivity for Result for external App not working

Community
  • 1
  • 1
14mcei
  • 43
  • 5

1 Answers1

0

I am able to invoke my App, but unable to pass data

If the caller uses startActivityForResult(), you can use setResult() and finish() at the appropriate point to set the result (in the form of an Intent) and return control to the original activity. For example, if you are presenting a list of items to the user, when the user taps on an item, you can create an Intent with details about the item (e.g., as string extras), pass that Intent to setResult(), and then call finish().

So I think something within intent filter is to be modified.

<intent-filter> elements have nothing technically to do with supplying a result.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • I have done the same you can see it here - http://stackoverflow.com/q/34488029/5602596 But I am getting ResultCode=0 at the moment Activity is invoked – 14mcei Dec 28 '15 at 13:06
  • @14mcei: I am not surprised. Get rid of `SecondActivity`, or merge its functionality into `MainActivity`. `startActivityForResult()` does not handle well the case when the started activity turns around and starts other activities. – CommonsWare Dec 28 '15 at 13:29
  • Suppose I move task of SecondActivity into MainActivity by creating Fragments, will it do ? – 14mcei Dec 28 '15 at 14:37
  • @14mcei: Presumably that will be OK. To be honest, I think that your use of `startActivityForResult()` here is inappropriate. `startActivityForResult()` is really for fairly simple situations, where the activity being started has to present a simple choice to users (e.g., pick a file, pick an activity) and return that to the caller. If the activity being started is complex enough to warrant multiple fragments (let alone downstream activities), I would not use `startActivityForResult()`, but instead fix the overall app architecture. – CommonsWare Dec 28 '15 at 14:48