2010-06-15 4 views
0

Android에서 트윗을 보내고 싶습니다. 다음 코드를 실행했습니다.하지만 어떤 트윗을 보낼 수 없습니다. 내가 만든 버튼이 실제로 작동하지 않습니다. 누구든지 전화를받을 수 있습니까?Android를 사용하여 트윗 보내기

이것은

import android.app.Activity; 

import android.content.ActivityNotFoundException; 
import android.content.Intent; 
import android.os.Bundle; 
import android.view.View; 
import android.view.View.OnClickListener; 
import android.widget.Button; 
import android.os.Bundle; 

public class TwidgitPublicIntent extends Activity implements OnClickListener { 

    private static final int TWIDGIT_REQUEST_CODE = 2564; 
    /** Called when the activity is first created. */ 
    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.main); 
     ((Button)findViewById(R.id.tweet_button)).setOnClickListener(this); 
     ((Button)findViewById(R.id.mention_button)).setOnClickListener(this); 
     ((Button)findViewById(R.id.retweet_button)).setOnClickListener(this); 
     ((Button)findViewById(R.id.message_button)).setOnClickListener(this); 
    } 
    public void onClick(View v) { 
     switch(v.getId()) { 
      case R.id.tweet_button: 

       // Standard tweet 
       Intent tIntent = new Intent("com.disretrospect.twidgit.TWEET"); 
       tIntent.putExtra("com.disretrospect.twidgit.extras.MESSAGE", "_message_in_here_"); 
       try { 
        this.startActivityForResult(tIntent, TWIDGIT_REQUEST_CODE); 
       } catch (ActivityNotFoundException e) { 
        // If Twidgit is not installed 
       } 

       break; 
      case R.id.mention_button: 

       // Mention 
       Intent mIntent = new Intent("com.disretrospect.twidgit.MENTION"); 
       mIntent.putExtra("com.disretrospect.twidgit.extras.TO", "_username_to_xmention_"); 
       mIntent.putExtra("com.disretrospect.twidgit.extras.MESSAGE", "_message_in_here_"); 
       try { 
        this.startActivityForResult(mIntent, TWIDGIT_REQUEST_CODE); 
       } catch (ActivityNotFoundException e) { 
        // If Twidgit is not installed 
       } 

       break; 
      case R.id.retweet_button: 

       // Retweet a tweet 
       Intent rtIntent = new Intent("com.disretrospect.twidgit.RETWEET"); 
       rtIntent.putExtra("com.disretrospect.twidgit.extras.MESSAGE", "_message_in_here_"); 
       rtIntent.putExtra("com.disretrospect.twidgit.extras.VIA", "_original_author_of_tweet_name_"); 
       try { 
        this.startActivityForResult(rtIntent, TWIDGIT_REQUEST_CODE); 
       } catch (ActivityNotFoundException e) { 
        // If Twidgit is not installed 
       } 

       break; 
      case R.id.message_button: 

       // Send DM 
       Intent dmIntent = new Intent("com.disretrospect.twidgit.DIRECT_MESSAGE"); 
       dmIntent.putExtra("com.disretrospect.twidgit.extras.TO", "_username_to_send_dm_to_"); 
       dmIntent.putExtra("com.disretrospect.twidgit.extras.MESSAGE", "_message_in_here_"); 
       try { 
        this.startActivityForResult(dmIntent, TWIDGIT_REQUEST_CODE); 
       } catch (ActivityNotFoundException e) { 
        // If Twidgit is not installed 
       } 

       break; 
     } 
    } 

    @Override 
    protected void onActivityResult(int requestCode, int resultCode, Intent data) { 
     super.onActivityResult(requestCode, resultCode, data); 

     // Check result code 
     if(resultCode == Activity.RESULT_OK) { 
      // Check requestCode 
      switch(requestCode) { 
       case TWIDGIT_REQUEST_CODE: 
        // Handle successful return 
       break; 
      } 
     } else if(resultCode == Activity.RESULT_CANCELED){ 
      // Handle canceled activity 
     } 
    } 
} 

답변

0

는 내가 대답에 넣고 필요가 귀하의 게시물을 수정할 수 없습니다 해요 .. 내 코드입니다 : 당신이 문제에 대한 자세한 내용을 제공 할 수있다? 좀 더 정확히 말하자면 "버튼이 작동하지 않는다"는 것은 무엇을 의미합니까? 버튼을 클릭하면 아무 일도 일어나지 않습니까? 아무 일도 일어나지 않으면 ActivityNotFoundException을 실행했을 수 있습니다. 그것은 붙잡 혔기 때문에, 아무런 조치도 취하지 않았으므로 투명합니다. onClick 메서드의 중단 점을 사용하여 디버깅을 시도 했습니까?

관련 문제