1

在我的 cn1 应用程序中,我想让用户能够备份自己的云存储。例如,您自己的 Dropbox 帐户。

我正在网上寻找解决方案。我认为我发现的(dropbox-codenameone-sdk)我只能管理一个已知帐户,因为我需要知道consumerSecret和consumerKey。当我编写代码时,我不知道实际的用户帐户信息。基于其他应用程序的操作,我假设我必须登录到实际用户他的帐户(例如 Dropbox)。

请帮助我可以执行哪些 API 调用。

4

2 回答 2

1

在 Display 中使用 Share API。您可以使用 zip cn1lib 压缩数据并将其保存在文件系统中的文件中,然后使用共享 API 让用户选择一个本地应用程序来共享它。在模拟器上它会有诸如电子邮件/脸书之类的选项,但在设备上你应该有更多选项。

于 2019-06-12T03:26:00.737 回答
0

我认为我正在正确使用 API。虽然我没有正确设置手机上的文件访问权限。

但是,错误发生在模拟器中。

我的安卓手机上的邮件和 DropBox 共享成功。我不喜欢文件获得前缀(IMG_20200112_204126_)。我可以改变这个吗?

我包括屏幕截图和代码片段。

最好的问候,彼得

图像1 图2 图3 图4 图5

public ShareForm(Resources resourceObjectInstance, Form parentForm) {
this.parentForm = parentForm; 
this.theme = resourceObjectInstance;

Layout layout = new BoxLayout(BoxLayout.Y_AXIS);
setLayout(layout);

getToolbar().setBackCommand("", e -> {
    this.parentForm.showBack();
});

/* file exist on simulator */
/*        String filePath = FileSystemStorage.getInstance().getAppHomePath() + "temp/vendeg_201807011754.json"; */
/* file exist on phone */
String filePath = "file:///storage/emulated/0/Download/stratos.pdf";

String mimeType = "application/octet-stream";

boolean exist = FileSystemStorage.getInstance().exists(filePath);
long size = FileSystemStorage.getInstance().getLength(filePath);

SpanLabel spanLabel0 = new SpanLabel("File path: " + filePath);
SpanLabel spanLabel1 = new SpanLabel("File exist: " + exist);
SpanLabel spanLabel2 = new SpanLabel("File size: " + size);

ShareButton shareButton = new ShareButton();
shareButton.setText("Share data (ShareButton)");
shareButton.addActionListener(e-> {
    shareButton.setImageToShare(filePath, mimeType);
    shareButton.actionPerformed(e);
});


Button shareButton1 = new Button("Share data (Share API in Display)");
FontImage.setMaterialIcon(shareButton1, FontImage.MATERIAL_SHARE);
shareButton1.addActionListener(e -> {
    Display.getInstance().share(null, filePath, mimeType, shareButton1.getBounds(new Rectangle()));
});

addComponent(spanLabel0);
addComponent(spanLabel1);
addComponent(spanLabel2);
addComponent(shareButton);
addComponent(shareButton1);

}

于 2020-01-12T20:32:59.300 回答