Search code examples
androidandroid-sharingweibo

Sharing with weibo sdk


I create app in my weibo dev account, got app key.
Weibo is installed on my phone. When I trying to share some text, nothing happens. In my activity only onPause() and onResume() triggered.

    mWeiboShareAPI = WeiboShareSDK.createWeiboAPI(getContext(), APP_KEY);
    boolean registered = mWeiboShareAPI.registerApp();
    Log.w(TAG, "registered ? -> " + registered); // returns true

    WeiboMultiMessage weiboMessage = new WeiboMultiMessage();
    weiboMessage.textObject = new TextObject();
    weiboMessage.textObject.text = "TEST";

    SendMultiMessageToWeiboRequest request = new SendMultiMessageToWeiboRequest();
    request.transaction = String.valueOf(System.currentTimeMillis());
    request.multiMessage = weiboMessage;

    boolean requesSent = mWeiboShareAPI.sendRequest(getActivity(), request);
    Log.w(TAG, "request sent ? -> " + requesSent); // returns true

In manifest I defined weibo activity and some stuff from example (https://github.com/sinaweibosdk/weibo_android_sdk).

 <activity android:name="com.sina.weibo.sdk.component.WeiboSdkBrowser"
    android:configChanges="keyboardHidden|orientation"
    android:windowSoftInputMode="adjustResize"
    android:exported="false" >
</activity>
<service android:name="com.sina.weibo.sdk.net.DownloadService"
    android:exported="false">
</service>
<meta-data
    android:name="WEIBO_APPKEY"
    android:value="2xxxxxx832" />
<meta-data
    android:name="WEIBO_CHANNEL"
    android:value="weibo" />

What did I missed, any suggestions? How can I understand what's the problem? Btw DownloadService is not defined. Rarely, after couple of seconds it is org.apache.http.conn.ConnectTimeoutException: Connect to /114.134.80.166:443 timed out appearing.


Solution

  • The problem was in wrong application type on weibo dev account, I recreated application, add package and md5 package hash, and now it works. But only if weibo application installed on phone. And you don't need any addition entities in manifest.