UserTimeline example not working on Android

android
fabric

#1

Hi,

I’m trying to test your UserTimeline example to work on Android, and it only says "No Tweets"
What I’m doing wrong?

The code from Timeline.java :

import android.app.ListActivity;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import com.twitter.sdk.android.Twitter;
import com.twitter.sdk.android.core.TwitterAuthConfig;
import com.twitter.sdk.android.tweetui.TweetTimelineListAdapter;
import com.twitter.sdk.android.tweetui.UserTimeline;

import io.fabric.sdk.android.Fabric;

public class Timeline extends ListActivity {

// Note: Your consumer key and secret should be obfuscated in your source code before shipping.
private static final String TWITTER_KEY = "";
private static final String TWITTER_SECRET = "";


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    TwitterAuthConfig authConfig = new TwitterAuthConfig(TWITTER_KEY, TWITTER_SECRET);
    Fabric.with(this, new Twitter(authConfig));
    setContentView(R.layout.timeline);

    final UserTimeline userTimeline = new UserTimeline.Builder()
            .screenName("fabric")
            .build();
    final TweetTimelineListAdapter adapter = new TweetTimelineListAdapter.Builder(this)
            .setTimeline(userTimeline)
            .build();
    setListAdapter(adapter);
 }
}

and from timeline.xml is :

 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView android:id="@id/android:empty"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center_horizontal|center_vertical"
    android:text="No Tweets"/>

<ListView android:id="@id/android:list"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:divider="#e1e8ed"
    android:dividerHeight="1dp"
    android:drawSelectorOnTop="false"/>
</LinearLayout>


#2

I’m not an expert but I guess if you want an application authentication you must configure “login button”.
Check this link:
https://docs.fabric.io/android/twitter/authentication.html

Hope it will work with you


#3

Thanks for the respond.
I think when you use UserTimeline you don’t need log in button or authentication key to work. Am I right?


#4

Any other help guys?
Nobody else worked with UserTimeline ?


#5

Hey @JEK_ZZ,

Sorry for the delay in responding. You do need to have an API key in order to show the UserTimeline.

These two values:

private static final String TWITTER_KEY = “”;
private static final String TWITTER_SECRET = “”;

should be filled in with your Twitter Consumer key and secret from your Fabric Twitter dashboard. The keys will be auto-generated when you first start using Fabric.

-Mike


#6

Yes,it works!
Thanks!, you can mark the topic as solved :smile:


#7

Glad to hear it and happy coding!


#8