无法从其他Facebook帐户上传图像

时间:2014-10-29 08:22:57

标签: android facebook image session android-permissions

我已经实现了Facebook集成t上传图片,它只能从我的帐户工作正常,我注销并尝试从其他帐户权限屏幕不断弹出

public void postImage() {
    if (checkPermissions()) {
        Bitmap bmp = null;
        String filename = getIntent().getStringExtra("image");
        try {

            FileInputStream is = this.openFileInput(filename);
            bmp = BitmapFactory.decodeStream(is);
            is.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

        Request uploadRequest = Request.newUploadPhotoRequest(
                Session.getActiveSession(), bmp, new Request.Callback() {

                    @Override
                    public void onCompleted(Response response) {
                        Toast.makeText(FacebookUpload.this,
                                "Photo uploaded successfully",
                                Toast.LENGTH_LONG).show();


                        File dir = getFilesDir();
                        File file = new File(dir, "bitmap.png");
                        file.delete();


                    }
                });


        // post on user's wall.
        Bundle params =uploadRequest.getParameters();
        Random rand = new Random();
        int rndInt = rand.nextInt(3)+1;
        if(rndInt==1)
        params.putString("name", "download Chummi-Lalli Mobile App from https://play.google.com/store/apps/details?id=com.interactive8.readmestories");
        else if(rndInt==2)
        params.putString("name","Send gifts to your loved ones from www.ekhudol.com");

        else if(rndInt==3)
            params.putString("name","Chummilalli brought to you by www.3leafsolutions.co.in");
        else
            params.putString("name","Chummilalli brought to you by www.3leafsolutions.co.in");
        uploadRequest.setParameters(params);
        uploadRequest.executeAsync();
    } 

    else {
        requestPermissions();
    }

}

这是requestpermission()和checkpermission()

public boolean checkPermissions() {
    Session s = Session.getActiveSession();
    if (s != null) {
        return s.getPermissions().contains("publish_actions");
    } else
        return false;
}

public void requestPermissions() {
    Session s = Session.getActiveSession();
    if (s != null)
        s.requestNewPublishPermissions(new Session.NewPermissionsRequest(
                this, PERMISSIONS));
}

似乎我的程序反复进入else requestPermission()部分,每当我从另一个帐户登录时,checkPermission()返回false。这里有什么问题,我已经尝试了3天,请帮助任何人

0 个答案:

没有答案