gpt4 book ai didi

Android Fabric Twitter 错误

转载 作者:太空狗 更新时间:2023-10-29 16:30:51 27 4
gpt4 key购买 nike

我正在使用 fabric 将 twitter 集成到我的应用程序中,因为我想向用户显示所有 friend /关注列表。

我成功获取了当前用户名和 ID,但是当我尝试获取以下列表时,它显示错误 Service methods cannot return void. in line ** new MyTwitterApiClient(session).getCustomService() .show** 我的代码如下。

请任何人帮我解决这个问题或任何其他方法来让用户关注列表。

我在 xml 文件中的 Twitter 按钮:

  <Button
android:id="@+id/btn_twitter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/ll_mainBar"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:background="@color/color_drawer_orange"
android:gravity="center"
android:hint="Twiiter"
android:padding="5dp"
android:textColor="@color/color_white"
android:textColorHint="@color/color_white" />

在我的类(class)文件中:

      btn_twitter.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

mTwitterAuthClient.authorize(SocialIntegrationFragment.this, new Callback<TwitterSession>() {
@Override
public void success(Result<TwitterSession> result) {
final TwitterSession session = Twitter.getSessionManager().getActiveSession();
Log.e(TAG, "UserName===================>" + session.getUserName());
Log.e(TAG, "UserId===================>" + session.getUserId());
Log.e(TAG, "ID===================>" + session.getId());
Log.e(TAG, "Token===================>" + session.getAuthToken());

// above all getting successfully

final String[] profile_image = {""};
final String[] email = {""};
final String[] name = new String[1];

// but getting error in following line : for getting following list

new MyTwitterApiClient(session).getCustomService().show(session.getId(), null, true, true, 100, new Callback<Followers>() {
@Override
public void success(Result<Followers> result) {
Log.i("Get success", "" + result.data.users.size());
}

@Override
public void failure(TwitterException e) {
Log.i("Get fail", "" + e.getMessage());
}
});

}

@Override
public void failure(TwitterException exception) {

}
});

}
});

//其他方法

 public class Followers {
@SerializedName("users")
public final List<User> users;

public Followers(List<User> users) {
this.users = users;
}
}

class MyTwitterApiClient extends TwitterApiClient {
public MyTwitterApiClient(TwitterSession session) {
super(session);
}

public CustomService getCustomService() {
return getService(CustomService.class);
}

}

interface CustomService {
@GET("/1.1/followers/list.json")
void show(@Query("user_id") Long userId, @Query("screen_name") String
var, @Query("skip_status") Boolean var1, @Query("include_user_entities") Boolean var2, @Query("count") Integer var3, Callback<Followers> cb);
}

我的错误日志如下:

   java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=140, result=-1, data=Intent { (has extras) }} to activity {com.app.SocialIntegrationFragment}: java.lang.IllegalArgumentException: Service methods cannot return void.
for method CustomService.show
at android.app.ActivityThread.deliverResults(ActivityThread.java:3319)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:3362)
at android.app.ActivityThread.access$1100(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1282)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5041)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalArgumentException: Service methods cannot return void.
for method CustomService.show
at retrofit2.ServiceMethod$Builder.methodError(ServiceMethod.java:695)
at retrofit2.ServiceMethod$Builder.methodError(ServiceMethod.java:686)
at retrofit2.ServiceMethod$Builder.createCallAdapter(ServiceMethod.java:227)
at retrofit2.ServiceMethod$Builder.build(ServiceMethod.java:159)
at retrofit2.Retrofit.loadServiceMethod(Retrofit.java:166)
at retrofit2.Retrofit$1.invoke(Retrofit.java:145)
at com.app.$Proxy8.show(Native Method)
at com.app.SocialIntegrationFragment$5$1.success(SocialIntegrationFragment.java:190)
at com.twitter.sdk.android.core.identity.TwitterAuthClient$CallbackWrapper.success(TwitterAuthClient.java:230)
at com.twitter.sdk.android.core.identity.AuthHandler.handleOnActivityResult(AuthHandler.java:92)
at com.twitter.sdk.android.core.identity.TwitterAuthClient.onActivityResult(TwitterAuthClient.java:161)
at com.app.SocialIntegrationFragment.onActivityResult(SocialIntegrationFragment.java:534)
at android.app.Activity.dispatchActivityResult(Activity.java:5293)
at android.app.ActivityThread.deliverResults(ActivityThread.java:3315)
... 11 more

请任何人帮我解决这个问题。

最佳答案

你应该试试这个方法

interface CustomService {
@GET("/1.1/followers/list.json")
Call<Followers> show(@Query("user_id") Long userId, @Query("screen_name") String
var, @Query("skip_status") Boolean var1, @Query("include_user_entities") Boolean var2, @Query("count") Integer var3);
}

new MyTwitterApiClient(session).getCustomService().show(session.getId(), null, true, true, 100).enqueue(YOUR_CALLBACK);

关于Android Fabric Twitter 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39289424/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com