0

アセットフォルダから画像を読み込もうとするフォトギャラリーアプリを作っています。私はこれを行うことに成功しています。

今度は、メール、フェイスブック、ツイッターで画像(複数ではなく単一)を共有したいと思います。これが私の問題の始まりです。アプリからわかりやすいメッセージを投稿することはできますが、画像を投稿したり、画像を添付したりすることはできません。これを行う方法がわかりません。私は多くのチュートリアルを試しましたが、助けにはなりませんでした。

4

3 に答える 3

0

Facebookがダウンロードできるように、最初にインターネット上のどこかに画像をアップロードする必要があります。

于 2012-08-17T12:09:28.897 に答える
0

Facebookの場合は、インターネットから取得できるFacebookAPiを使用します。

アンドロイドのツイッターとフェイスブックでテキスト/画像を共有する

于 2012-08-17T12:11:02.013 に答える
0

ほら、それは私のために働く:

final Session session = Session.getActiveSession();
if (session != null){
// check publish permissions here
// if there is no permission request it and return;
//else if there is permission
logMessage("Has permission go on");
        final Bundle postParams = new Bundle();
        if(File("yourImagePath").exists())
        {
            byte[] data = null;
                    File screenShotFile = new File("yourImagePath");
            logMessage("getting screenShot here");
            FileInputStream fis = new FileInputStream(screenShotFile);
            Bitmap bitmap = BitmapFactory.decodeStream(fis);
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
            data = baos.toByteArray();  
            postParams.putByteArray("picture", data);

           logMessage("added pic as byte array to params");
        }
        postParams.putString("name", "Post name");
        postParams.putString("caption", "caption");
        postParams.putString("description", "desc");
        postParams.putString("link", "http://www....");
            final Request.Callback callback= new Request.Callback() {
            public void onCompleted(Response response) 
            {
                FacebookRequestError error;
                try {
                    error = response.getError();
                    if (error != null) 
                    {
                        makeToast(error.getErrorMessage());
                        logMessage(error.getErrorMessage());
                    } 
                    else 
                    {
                        // no errors so delete image here
                        if(screenShotFile != null)
                        {
                            screenShotFile.delete();
                            logMessage("deleted");
                            screenShotFile = null;
                        }
                    }
                } catch (Exception e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                logMessage(response.toString());
            }
        };
Request request = new Request(session, "me/photos", postParams, 
                              HttpMethod.POST, callback);
                    RequestAsyncTask task = new RequestAsyncTask(request);
                    task.execute();
logMessage("made feed request check");
         }
于 2014-01-24T15:17:55.933 に答える