Where to add API key for Twitter Android Key

I'm a little confused as to where I need to put the API keys for the Twitter Kit for Android. Searching the web is mostly related to the Fabric API which I am not using

As per the dev section on twitter, it says to put the key here: ( https://dev.twitter.com/twitterkit/android/installation )

 Next, add your API key and secret to your application resources.

 <resources>
   <string 
 android:name="com.twitter.sdk.android.CONSUMER_KEY">XXXXXXXXXXX</string>
   <string 
 android:name="com.twitter.sdk.android.CONSUMER_SECRET">XXXXXXXXXXX</string>
 </resources>

      

Will it just be in Strings.xml? It doesn't seem to look like android: name when it's in the string.xml file. It seems that the Fabric API has its key placed in the AndroidManifest file as metadata. It doesn't seem to be too clear where this should be put. I guess this is not for me because I cannot get any tweets from the UserTimeLine to download.

+3


source to share


2 answers


set this @onCreate to your target activity.



TwitterConfig config = new TwitterConfig.Builder(this)
                .logger(new DefaultLogger(Log.DEBUG))
                .twitterAuthConfig(new TwitterAuthConfig(getString(R.string.CONSUMER_KEY), getString(R.string.CONSUMER_SECRET)))
                .debug(true)
                .build();
        Twitter.initialize(config);

      

+1


source


I find the docs are also misleading. Perhaps they will edit it in the future. Yes, you can wear it strings.xml

. You just need to omit the prefix android

.

<resources>
    <string name="app_name">SampleTwitterClient</string>
    <string name="action_settings">Settings</string>

    <string name="com.twitter.sdk.android.CONSUMER_KEY">asdfasdf</string>
    <string name="com.twitter.sdk.android.CONSUMER_SECRET">asdfasdf</string>
</resources>

      



Adding it to AndroidManifest.xml meta-data

won't work. It is used by Fabric, not Twitter SDK.

+3


source







All Articles