Thanks for your interest in the Flow research beta. At this time, we’ve concluded our research and the beta is no longer available. Please continue to the official Samsung Flow Page to learn more.

Samsung Flow for developers

Samsung Flow isn't just an application; it's a platform that allows applications to seamlessly transition a user's activities across their devices and across time. This page provides you, the developer, with the information and resources you need to integrate your own applications with Flow.

Flow provides two ways for applications to integrate with it: through Android's Share intent, and by directly providing a Flow intent.

Direct Integration

Direct Integration

  • 1. Look for the Flow action and tap it.

  • 2. Choose the device or to resume later.

While Share integration is the simplest and fastest way for your application to integrate with Flow, it doesn't necessarily provide the best experience for your users. By providing a Flow action in your application you can directly integrate with Flow and take full control over how your application transfers and defers a user's activities.

Direct integration requires a little more work, but can often be added to an application with only 15-20 lines of code. See the Direct Integration documentation for details.

Direct Integration

Share integration is lightweight and easy to achieve, but the amount of data your application can encode to describe a user's activity is limited by what you can encode in a URL. If you'd like richer control over transferring and deferring activities, your application can directly integrate with Flow. With direct integration you can encode the state of the user's current activity as a set of key-value pairs, and then later use that same state to restore a transferred or deferred activity.

To directly integrate with Flow, your application provides a Flow action that's accessible to users wherever you want them to be able to transfer or defer their activities. We provide light and dark Flow action icons that you can use in your applications for this action.

Not all devices will have Flow installed, so it's good practice to check to see if Flow is available before showing or enabling the Flow icon for your action. Android makes that easy.

private boolean isFlowInstalled() {
    PackageManager pkgManager = getApplicationContext().getPackageManager();

    try {
        pkgManager.getPackageInfo("com.samsung.flow", 0);
        return true;
    } catch (PackageManager.NameNotFoundException e) {
        return false;
    }
}

Once you've verified that Flow is installed and added a Flow icon to your application’s user interface, you need to implement the action that makes a request to Flow. Flow supports two types of requests: private and public.

Private requests allow you to bundle the state describing the user's activity as an intent that Flow will deliver as-is to the receiving device (whether transferring or resuming). That provides your application a create deal of flexibility in how it formats the user's state. For security purposes, however, Flow will only deliver private requests to applications with the same signature. The requests are thus private to your own applications.

Public requests allow your applications to transfer or defer activities to applications that may be written by other developers. In exchange for this increased flexibility, however, Flow imposes restrictions on the structure of the request. In addition, the receiving application must explicitly opt-in to receiving public Flow requests.

Creating A Private Request

To create a private request, your application needs to:

1. Bundle any state necessary to describe the user's activity into an intent that Flow will deliver to the remote (or resuming) device.

Intent remoteIntent = new Intent(MY_REMOTE_ACTION);
remoteIntent.putExtra(STATE_KEY, someStateValue);
remoteIntent.putExtra(ANOTHER_STATE_KEY, anotherStateValue);

2. Add a name and description for Flow to use if the user defers the activity.

remoteIntent.putExtra("com.samsung.flow.activity_name", "An Activity Name");

remoteIntent.putExtra("com.samsung.flow.activity_description",
"A more detailed description of the activity.");

3. Optional: add a fallback URL that Flow will use if no application is available to handle the intent on the receiving device.

remoteIntent.putExtra("com.samsung.flow.fallback_url", "http://www.example.com/some/activity");

4. Create a pending intent for Flow to use to provide progress updates.

Intent callback = new Intent(this, MyActivity.class);
PendingIntent pendingIntent = createPendingResult(REQUEST_CODE_CALLBACK, callback, 0);

5. Create a private Flow request intent, add the remote and pending intents, and send it.

Intent intent = new Intent("com.samsung.flow.PRIVATE_FLOW_REQUEST");
intent.setPackage("com.samsung.flow");

intent.putExtra("com.samsung.flow.remote_intent", remoteIntent);
intent.putExtra("com.samsung.flow.callback", pendingIntent);

startActivityForResult(intent, REQUEST_CODE_START);

6. On the receiving device, use the bundled state to restore the user's activity.

Intent intent = getIntent();
String someStateValue = intent.getStringExtra(STATE_KEY);
int anotherStateValue = intent.getIntExtra(ANOTHER_STATE_KEY,-1);

You can check out the Private Flow Request Sample Project for an example of direct Flow integration via a private request.

Creating A Public Request

Since public requests are more constrained, creating one requires a few additional steps:

1. Create a public Flow request intent.

Intent flowIntent = new Intent("com.samsung.flow.PUBLIC_FLOW_REQUEST");

2. Specify the action that Flow will assign to the intent it creates on the remote device.

flowIntent.putExtra("com.samsung.flow.remote_action", "com.example.ACTION");

3. Optional: specify a particular activity that you want Flow to deliver the intent to on the remote device.

flowIntent.putExtra("com.samsung.flow.remote_package", "com.example");

flowIntent.putExtra("com.samsung.flow.remote_class", "com.example.AnActivity");

4. Add a name and description for Flow to use if the user's defers the activity.

flowIntent.putExtra("com.samsung.flow.activity_name", "An Activity Name");

flowIntent.putExtra("com.samsung.flow.activity_description",
"A detailed description of the activity.");

5. Optional: add a fallback URL that Flow will use if no application is available to handle the intent on the receiving device.

flowIntent.putExtra("com.samsung.flow.fallback_url", "http://www.example.com/some/activity");

6. Create a bundle that contains key-value pairs describing the user's activity and add it to the intent.

Bundle remoteData = new Bundle();
remoteData.putString(STATE_KEY, stateValue);
flowIntent.putExtra("com.samsung.flow.remote_data", remoteData);

7. Optional: create a pending intent for Flow to use to provide progress updates.

Intent callback = new Intent(this, MyActivity.class);
PendingIntent pi = createPendingResult(REQUEST_CODE_CALLBACK, callback, 0);
flowIntent.putExtra("com.samsung.flow.callback", pi);

8. Send the intent

startActivity(flowIntent);

9. In order to receive a public Flow request, an activity must explicitly opt-in by providing a suitable filter.

<intent-filter>
    <action android:name="com.example.ACTION" />
    <category android:name="com.samsung.flow.PUBLIC_DELIVERY" />
</intent-filter>

10. On the receiving device, the provided bundled state data will be available directly from the delivered intent.

Intent intent = getIntent();
String someStateValue = intent.getStringExtra(STATE_KEY);

Check out the Public Flow Request Sample Project for an example of direct Flow integration via a public request.

Resources

If you just want to tune your Share intent to work a bit better with Flow, our Sample Share Integration Project will show you what to do.

If you'd like to directly integrate with Flow, use one of our action icons to add a Flow action to your UI, and be sure to check out our Private Flow Request and Public Flow Request sample projects.

  • Light icon

  • Dark icon

  • Click below to download the icon package. Graphic files contain transparency.

    Flow Icon Package (75kb)