无法从Android的发送文本文件的Dropbox [英] Can not send text file to dropbox from android

查看:162
本文介绍了无法从Android的发送文本文件的Dropbox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想了很多发送文本文件下拉框,但它不工作。按我的知识,我也得当所有编码。有人请给我您的电子邮件ID或回复我的Lalit12131@gmail.com
我会送你我的所有文件和细节,让我解决这个问题。

请帮助
先谢谢了。

 无效toDropbox()
{
    b1.setOnClickListener(新OnClickListener(){
        @覆盖
        公共无效的onClick(查看为arg0){
            // TODO自动生成方法存根
            串文件路径= getApplicationContext()getFilesDir()的getPath()的toString()+/DropboxFile1.txt。;
            档案文件=新的文件(文件路径);             尝试{
                file.createNewFile();
            }赶上(IOException异常五){
                // TODO自动生成catch块
                e.printStackTrace();}             的FileInputStream的InputStream = NULL;
            尝试{
                的InputStream =新的FileInputStream(文件);
            }赶上(FileNotFoundException异常五){
                // TODO自动生成catch块
                e.printStackTrace();
            }            Toast.makeText(getBaseContext(),以clickListener,Toast.LENGTH_SHORT).show();
             尝试{
                DropboxAPI.Entry响应= mDBApi.putFile(/ DropboxFile1.txt的InputStream,file.length(),NULL,NULL);
            }赶上(DropboxException E){
                // TODO自动生成catch块
                e.printStackTrace();
            }


解决方案

<一个href=\"http://grep$c$c.com/file/repo1.maven.org/maven2/org.syncloud/dropbox.java.api/1.3.1.1/com/dropbox/client2/exception/DropboxUnlinkedException.java/\"相对=nofollow>这意味着你得到的用户无关联的异常的,因为无论你需要检查是否正确安装Dropbox的,让你的应用程序能够访问和/或你没有提供这是给你提供了正确的访问令牌对时您设定接入(在Dropbox的网站)。

这会发生是因为你没有设置在您的会话的com.dropbox.client2.session.AccessTokenPair,或者因为用户断开了您的应用程序(撤销访问令牌对)。

首先去的Dropbox,并按照指示在这里:开发人员指南并确保你已经安装的应用程序的权限,并确保用户(您)已经允许应用程序(链接)的访问。你应该给予的访问键的和的访问秘密的,你需要把你的应用程序。通过@Hassaan拉巴尼提供的答案有使用的应用程序键和秘密令牌验证对您的应用程序的一个例子。请注意,当你尽了code,我敢肯定,你一定已经改变了变量

 最终静态私人字符串APP_KEY =XXXXXXXXX;
最终静态私人字符串APP_SECRET =XXXXXXXXX;

令牌对给你。如果你没有改变这些值到正确的人,则表示该错误是服务器端,以便仔细检查,从我所提供的链接的权限。

要获取应用程序键和秘密你需要设置在Dropbox的应用程序。去创造新的应用,然后选择:

的Dropbox API,文件和数据存储,没有,所有文件类型,Your_App_Name

接下来的页面将显示您的钥匙。

I am trying a lot to send a text file to drop-box but it is not working. As per my knowledge i have done all the coding properly. Someone please give me your email-id or reply me on Lalit12131@gmail.com I will send you all of my files and details and let me solve this problem.

Please HELP Thanks in advance.

void toDropbox()
{
    b1.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            String filePath =getApplicationContext().getFilesDir().getPath().toString() + "/DropboxFile1.txt";
            File file = new File(filePath);

             try {
                file.createNewFile();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();}

             FileInputStream inputStream = null;
            try {
                inputStream = new FileInputStream(file);
            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

            Toast.makeText(getBaseContext(), "In clickListener", Toast.LENGTH_SHORT).show();
             try {
                DropboxAPI.Entry response = mDBApi.putFile("/DropboxFile1.txt", inputStream, file.length(), null, null);
            } catch (DropboxException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

解决方案

This suggests that you are getting the user unlinked exception because either you need to check that you correctly setup Dropbox to allow your app to have access and/or you are not providing the correct access token pair that was provided to you when you setup the access (on the Dropbox site).

"This will happen either because you have not set an com.dropbox.client2.session.AccessTokenPair on your session, or because the user unlinked your app (revoked the access token pair)."

First go to Dropbox and follow the instructions here: Developer Guide and make sure that you have setup app permissions, and make sure that the user (you) have allowed access for the app (linked). You should be given an access key and an access secret that you will need to put into your app. The answer provided by @Hassaan Rabbani has an example of authenticating your app using the app key and secret token pair. Note, that when you tried his code, I'm sure you must have changed the variables

final static private String APP_KEY = "xxxxxxxxx";
final static private String APP_SECRET = "xxxxxxxxx";

to the token pair given you. If you did change those values to the correct ones, it indicates that the error is server side so double check the permission from the link I provided.

To get the app key and secret you need to setup the app on Dropbox. Go to create new app and choose:

Dropbox api, Files and datastores, No, All file types, Your_App_Name

The next page will display your key.

这篇关于无法从Android的发送文本文件的Dropbox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆