Android: Fabric User Timeline Not Working -
i followed documentation , project appeared set fine. however, when run project app displaying "no tweets' textview, not timeline. code in doc, cuz wanna see working first before else.
here's activity's oncreate:
protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_social); try{ twitterauthconfig authconfig = new twitterauthconfig(twitter_key, twitter_secret); fabric.with(this, new twitter(authconfig)); final usertimeline usertimeline = new usertimeline.builder() .screenname("fabric") .build(); final tweettimelinelistadapter adapter = new tweettimelinelistadapter(this, usertimeline); setlistadapter(adapter); }catch(exception ex){ }
and here xml:
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" app:layout_behavior="@string/appbar_scrolling_view_behavior" tools:context="org.witrackclub.wtc.socialactivity" tools:showin="@layout/activity_social"> <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>
help appreciated
well, think problem keys (consumerkey & consumersecret).
androidmanifest.xml
<application ... android:name="timelinefabricapplication" ...
the application: timelinefabricapplication.java
import android.app.application; import com.twitter.sdk.android.twitter; import com.twitter.sdk.android.core.twitterauthconfig; import io.fabric.sdk.android.fabric; public class timelinefabricapplication extends application{ @override public void oncreate() { super.oncreate(); twitterauthconfig authconfig = new twitterauthconfig("consumerkey", "consumersecret"); fabric.with(this, new twitter(authconfig)); } }
the activity: mainactivity.java
import android.app.listactivity; import android.os.bundle; import com.twitter.sdk.android.tweetui.tweettimelinelistadapter; import com.twitter.sdk.android.tweetui.usertimeline; public class mainactivity extends listactivity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); final usertimeline usertimeline = new usertimeline.builder() .screenname("fabric") .build(); final tweettimelinelistadapter adapter = new tweettimelinelistadapter.builder(this) .settimeline(usertimeline) .build(); setlistadapter(adapter); } }
and layout: activity_main.xml
<?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>
my result:
the keys helped me found myself in fabric.io of created application. sure created app on fabric.io user?
in logcat or androidmonitor, see like: failed app auth token com.twitter.sdk.android.core.twitterapiexception: 403 forbidden
Comments
Post a Comment