2014-01-16 37 views
1

我試圖通過我的Twitter帳戶上的Android應用程序發佈我的數據,所以我應該怎麼做。 我已經嘗試了一種方法,下面是代碼,並且它顯示了我帳戶中的數據,我需要點擊推文按鈕才能使用它。所以我可以知道如何直接發佈它而不要求我發推文。像Four Square應用提前從我的Twitter帳戶的Android應用程序發佈數據作爲鳴叫

public void open(View view){ 
     String text = "Share Your Experiance ....!!!"; 
     String url = "twitter://post?message="; 

     try { 
      Intent i = new Intent(Intent.ACTION_VIEW); 
      i.setData(Uri.parse(url + Uri.encode(text))); 
      startActivity(i); 
     } catch (android.content.ActivityNotFoundException e) { 
      Toast.makeText(this, "Can't send tweet! Please install twitter...", 2).show(); 
     } 

謝謝!

+0

使用社交認證庫 – jyomin

回答

0

首先,您必須檢查您是否使用twitter登錄,或者不能將您的條件應用於此代碼段。

我認爲你在代碼中遵循所有基本的twitter集成。

public void uploadPic(String message, String getImgUrl) 
     throws Exception { 
     try { 
      System.out.println(" ON UPLOAD PIC FUNCTION getImgUrl "+getImgUrl); 
      // URL url = new URL("http://faveplatewebservice.siplstudio.com/uploads/big_dish/oooo14n7464rO4_thumb.png"); 
      URL url = new URL(getImgUrl); 
      URLConnection urlConnection = url.openConnection(); 
      InputStream in = new BufferedInputStream(urlConnection.getInputStream()); 

      StatusUpdate status = new StatusUpdate("Check Out FavPlates on appstore, which offers you to add and find exciting dishes near you. "+message); 
      //status.setMedia(file); 
      status.setMedia("Check Out FavPlates on appstore, which offers you to add and find exciting dishes near you. "+message, in); 

      mTwitter.updateStatus(status); 
     } catch (TwitterException e) { 
      Log.d("TAG", "Pic Upload error" + e.getExceptionCode()); 
      throw e; 
     } 
    } 

希望它能幫助你!

如果你卡在任何地方然後通知我。

謝謝!

相關問題