簡體   English   中英

從Android應用程序在Facebook,Twitter上分享圖像和文本

[英]Share Image and Text in Facebook,Twitter from Android Application

我正在一個應用程序中工作,我可以將我的畫廊圖像分享到facebook,twitter

我搜索了一些鏈接..所有人都提到了意向服務..但我不知道它將如何在我的應用程序中使用,如果有人幫我完整的代碼,我真的很感激

            Intent share = new Intent(Intent.ACTION_SEND);
            share.setType("image/jpeg");

            share.putExtra(Intent.EXTRA_STREAM,
              Uri.parse("file:///sdcard/DCIM/Camera/myPic.jpg"));

            startActivity(Intent.createChooser(share, "Share Image"));

試試這段代碼:

    Button button = (Button)findViewById(R.id.facebookButton);

    button.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
                    String path = "path to the image";
                    Uri imageUri = Uri.parse(path);

                    Intent sharingIntent = new Intent(Intent.ACTION_SEND);
                    sharingIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    sharingIntent.putExtra(Intent.EXTRA_STREAM, imageUri);
                    sharingIntent.setType("image/png");

                     startActivity(Intent.createChooser(sharingIntent , "Send image using.."));

        }
    });

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM