Android facebook SDK, upload pictures to wall with profile in different language?

后端 未结 3 1323
失恋的感觉
失恋的感觉 2020-12-11 13:01

Currently I\'m able to post mesages and pictures to my wall using my app, by looking for the album \"Wall Photos\" it works fine so far, i let a friend of mine to test my ap

3条回答
  •  南笙
    南笙 (楼主)
    2020-12-11 13:43

    Post your code how you are uploading image to facebook. And this is one sample code which is working fine for me just have a look might be helpful to you. And in my code am not creating any album Wall Photos. My picture gets uploaded in wall itself. Just have a look ...

    private void fbImageSubmit() {
        if (facebook != null) {
            if (facebook.isSessionValid()) {
                try {
                    byte[] data = null;
    
                    // Bitmap bi = BitmapFactory.decodeFile(Constants.imgShare);
                    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    
                    bmScreen.compress(Bitmap.CompressFormat.JPEG, 100, baos);
                    data = baos.toByteArray();
    
                    Bundle parameters = new Bundle();
                    parameters.putString("message", strmsg);
                    parameters.putString("method", "photos.upload");
                    parameters.putByteArray("picture", data);
    
                    facebook.request(null, parameters, "POST");
                    /*
                     * time = Calendar.getInstance().getTime().getHours() + ":"
                     * + Calendar.getInstance().getTime().getMinutes();
                     */
    
                    currentTime = DateFormat.format("hh:mm", d.getTime());
                    currentDate = DateFormat.format("dd/MM/yyyy", d.getTime());
    
                    Cursor cursor = Constants.dbHelper
                            .GetDataFromImageName(Constants.enhancedImage
                                    .getImagename());
                    if (cursor.getCount() > 0) {
                        Constants.dbHelper.updateData(currentDate.toString(),
                                currentTime.toString(), "Facebook", "Image");
                    } else {
                        Constants.dbHelper.insertData("true");
                    }
                    Toast.makeText(getApplicationContext(),
                            "Image uploaded successfully.", Toast.LENGTH_LONG)
                            .show();
    
                } catch (Exception e) {
                    // TODO: handle exception
                    System.out.println(e.getMessage());
                }
            }
        }
    }
    

    // bmscreen is my bitmap of image ; Hope might be helpful to you.

提交回复
热议问题