Problem in integrating twitter with android
I want to integrate twitter to my android app for that I have referred link
I have used the code for my main activity`Twitter my_twiter;
Button btn_login;
EditText edit_user_name;
EditText edit_password;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
btn_login = (Button) findViewById(R.id.main_loin_button);
edit_user_name = (EditText) findViewById(R.id.main_username_edit_text);
edit_password = (EditText) findViewById(R.id.main_password_edit_text);
btn_login.setOnClickListener(this);
}
@SuppressWarnings("deprecation")
@Override
public void onClick(View v)
{开发者_开发问答
String userName = edit_user_name.getText().toString();
String password = edit_password.getText().toString();
my_twiter = new Twitter(userName,password);
if(my_twiter == null)
{
Toast.makeText(TwitActivty.this, "Incorrect Login",Toast.LENGTH_LONG).show();
}
else
{
// Toast.makeText(TwitActivty.this, "Worked",Toast.LENGTH_LONG).show();
try
{
Log.i("Twitter Status :",my_twiter.getStatus()+"");
Intent intent = new Intent(TwitActivty.this,Twitter_Info_Activity.class);
startActivity(intent);
}
catch(Exception e)
{
e.printStackTrace();
}
}
}`
But I am getting the Exception
>
07-04 13:47:37.224: WARN/System.err(840): winterwell.jtwitter.TwitterException$E401: Unauthorized 07-04 13:47:37.224: WARN/System.err(840): http://api.twitter.com/1/statuses/user_timeline.json?count=6& () 07-04 13:47:37.233: WARN/System.err(840): at winterwell.jtwitter.URLConnectionHttpClient.processError(URLConnectionHttpClient.java:364) 07-04 13:47:37.233: WARN/System.err(840): at winterwell.jtwitter.URLConnectionHttpClient.connect(URLConnectionHttpClient.java:198) 07-04 13:47:37.233: WARN/System.err(840): at winterwell.jtwitter.URLConnectionHttpClient.getPage(URLConnectionHttpClient.java:239) 07-04 13:47:37.243: WARN/System.err(840): at winterwell.jtwitter.Twitter.getStatus(Twitter.java:2244) 07-04 13:47:37.243: WARN/System.err(840): at com.twit.TwitActivty.onClick(TwitActivty.java:51) 07-04 13:47:37.243: WARN/System.err(840): at android.view.View.performClick(View.java:2408) 07-04 13:47:37.253: WARN/System.err(840): at android.view.View$PerformClick.run(View.java:8816) 07-04 13:47:37.253: WARN/System.err(840): at android.os.Handler.handleCallback(Handler.java:587) 07-04 13:47:37.263: WARN/System.err(840): at android.os.Handler.dispatchMessage(Handler.java:92) 07-04 13:47:37.263: WARN/System.err(840): at android.os.Looper.loop(Looper.java:123) 07-04 13:47:37.263: WARN/System.err(840): at android.app.ActivityThread.main(ActivityThread.java:4627) 07-04 13:47:37.273: WARN/System.err(840): at java.lang.reflect.Method.invokeNative(Native Method) 07-04 13:47:37.273: WARN/System.err(840): at java.lang.reflect.Method.invoke(Method.java:521) 07-04 13:47:37.293: WARN/System.err(840): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) 07-04 13:47:37.303: WARN/System.err(840): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 07-04 13:47:37.303: WARN/System.err(840): at dalvik.system.NativeStart.main(Native Method)
I am not getting where I am wrong OR tell me better alternative way to integrate with twitter please Help Me
精彩评论