Skip to content
This repository was archived by the owner on Jul 27, 2019. It is now read-only.

Commit 8f099f0

Browse files
committed
Adde sendToDesktop() helper method.
1 parent 3395d2e commit 8f099f0

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

send-to-desktop-api/app/src/main/java/com/adobe/sendtodesktopapi/MainActivity.java

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
package com.adobe.sendtodesktopapi;
22

33
import android.content.Intent;
4+
import android.graphics.Bitmap;
45
import android.net.Uri;
56
import android.os.Bundle;
7+
import android.provider.MediaStore;
68
import android.support.design.widget.FloatingActionButton;
79
import android.support.design.widget.Snackbar;
810
import android.support.v7.app.AppCompatActivity;
@@ -13,11 +15,18 @@
1315
import android.view.View;
1416
import android.widget.Button;
1517
import android.widget.ImageView;
18+
import android.widget.Toast;
1619

1720
import com.adobe.creativesdk.foundation.auth.AdobeAuthException;
1821
import com.adobe.creativesdk.foundation.auth.AdobeAuthSessionHelper;
1922
import com.adobe.creativesdk.foundation.auth.AdobeAuthSessionLauncher;
2023
import com.adobe.creativesdk.foundation.auth.AdobeUXAuthManager;
24+
import com.adobe.creativesdk.foundation.sendtodesktop.AdobeCreativeCloudApplication;
25+
import com.adobe.creativesdk.foundation.sendtodesktop.AdobeSendToDesktopApplication;
26+
import com.adobe.creativesdk.foundation.sendtodesktop.AdobeSendToDesktopException;
27+
import com.adobe.creativesdk.foundation.sendtodesktop.IAdobeSendToDesktopCallBack;
28+
29+
import java.io.IOException;
2130

2231
public class MainActivity extends AppCompatActivity {
2332

@@ -98,6 +107,34 @@ public void onClick(View v) {
98107

99108
}
100109

110+
private void sendToDesktop() throws IOException {
111+
/* 1) Get the image Bitmap */
112+
Bitmap bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), mSelectedImageUri);
113+
114+
/* 2) Specify the Adobe desktop app to send to */
115+
AdobeCreativeCloudApplication creativeCloudApplication = AdobeCreativeCloudApplication.AdobePhotoshopCreativeCloud;
116+
117+
/* 3) Make a callback to handle success and error */
118+
final IAdobeSendToDesktopCallBack sendToDesktopCallBack = new IAdobeSendToDesktopCallBack() {
119+
@Override
120+
public void onSuccess() {
121+
// Success case example
122+
Toast.makeText(MainActivity.this, "Opening in Photoshop on your desktop!", Toast.LENGTH_LONG).show();
123+
}
124+
125+
@Override
126+
public void onError(AdobeSendToDesktopException e) {
127+
// Error case example
128+
Toast.makeText(MainActivity.this, "Failed!", Toast.LENGTH_LONG).show();
129+
130+
e.printStackTrace();
131+
}
132+
};
133+
134+
/* 4) Send the image to the desktop! */
135+
AdobeSendToDesktopApplication.sendImage(bitmap, creativeCloudApplication, "My image title", sendToDesktopCallBack);
136+
}
137+
101138
@Override
102139
protected void onResume() {
103140
super.onResume();
@@ -137,7 +174,7 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {
137174

138175
mSelectedImageUri = data.getData();
139176
mSelectedImageView.setImageURI(mSelectedImageUri);
140-
177+
141178
}
142179
}
143180

0 commit comments

Comments
 (0)