나는 많은 다른 방법을 시도하고 OAuth로 JTwitter를 사용하는 자습서를 찾기 위해 인터넷 전체를 검색합니다. 여기에 나는 Jtwitter 및 표지판 모두가 만든 자바 빌더Android 용 간단한 JTwitter 예 :
에 항아리로
public class ShareGenerator extends Activity {
private static final String JTWITTER_OAUTH_KEY = "this_is_populated";
private static final String JTWITTER_OAUTH_SECRET = "this_is_populated";
Button menupopButton;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.share);
this.setContentView(R.layout.share);
this.txShare = (TextView)this.findViewById(R.id.lblshare);
this.menupopButton = (Button)this.findViewById(R.id.menupop);
menupopButton.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v)
{
TwitterSend();
}
});
}
을 실행하는 간단한 버튼을 추가
다운로드를 달성 다음 단계를하고 난 내 클래스가 있습니다
public void TwitterSend() {
OAuthSignpostClient client = new OAuthSignpostClient(JTWITTER_OAUTH_KEY, JTWITTER_OAUTH_SECRET, "oob");
Twitter jtwit = new Twitter("bob", client);
// open the authorisation page in the user's browser
client.authorizeDesktop();
// get the pin
String v = client.askUser("Please enter the verification PIN from Twitter");
client.setAuthorizationCode(v);
// Optional: store the authorisation token details
Object accessToken = client.getAccessToken();
// use the API!
jtwit.setStatus("Messing about in Java");
}
그러나 OAuth 화면이 팝업 될 수도 없습니다. 도착하면 충돌합니다. 누구나 적어도 OAuth 화면을 볼 수 있습니까? 가져 오기를 올바르게 설정했습니다. 하지만 안드로이드에
// open the authorisation page in the user's browser
client.authorizeDesktop();
데스크탑 PC에서 작동합니다 :
Logcat에서 크래시에 대해 알려주는 내용을 확인하고 매니페스트에 인터넷 사용 권한이 있는지 확인하십시오. – Pentium10
Logcat은 java.lang.NoClassDefFoundErrors를 말합니다 : java.awt.Desktop 그것은 client.authorizeDesktop()에서 실패하고 있습니다; – JuniorFlip
setData() 메서드에서 url을 전달하기 위해 URI를 Uri로 변환 할 수 없습니다. 그렇게 할 제안이 있습니까? –