# API open interface

# 1. Account system

In the case of networking, the initial machine will have an openId which will only change after binding if it is unbound by the administrator. Unbundling by the administrator will reset the watch system, making it equivalently new. The method of obtaining is as follows:

private static final String CONTENT_OPENID_TYPE = "content://com.xtc.provider/BaseDataProvider/openID/8";
context.getContentResolver().getType(Uri.parse(CONTENT_OPENID_TYPE));

The minimum supported versions are XTC Z2_V1.5.6、XTC Z3_V1.2.6、XTC Z5_V1.2.6、XTC Z6_V1.0.0、imoo Z5_1.1.1

# 2.Sharing function

# 2.1 Obtain sharing capability

  • Contact imoo personnel to apply for a shared AppKey.

  • Introduce jar package

# 2.2 Check if the version supports your requirements

If there are special requirements, you can check first and then share, otherwise you don't need to execute it. In the SDK, if the version is not supported, a Toast popup will appear by default, indicating that the current version does not support sharing to XX.

//Query whether to support sharing to chat

boolean isSupport = new ShareMessageManager(context).checkBaseVersion(Scene.TYPE_CHAT);
//Query whether to support sharing to friend circle

boolean isSupport = new ShareMessageManager(context).checkBaseVersion(Scene.TYPE_MOMENT);

# 2.3 Share specified content types

  • Share text type
//Step 1: Create an object of XTCTextObject and set the text property to the text content to be shared

XTCTextObject xtcTextObject = new XTCTextObject();
xtcTextObject.setText("Sharing from test program");

//Step 2: Create an object of XTCShareMessage and set the property of shareObject to the object of xtcTextObject

XTCShareMessage xtcShareMessage = new XTCShareMessage();
xtcShareMessage.setShareObject(xtcTextObject);

//Step 3: Create an object of SendMessageToXTC.Request and set it

SendMessageToXTC.Request request = new SendMessageToXTC.Request();
request.setMessage(xtcShareMessage);

//Step 4: Create an object of ShareMessageManagr, call the method of sendRequestToXTC, and pass in the object of SendMessageToXTC.Request and AppKey

new ShareMessageManager(this).sendRequestToXTC(request, "appkey");
  • Share image type
//Step 1: Create an object of XTCImageObject and set the property of bitmap to the image to share

XTCImageObject xtcImageObject = new XTCImageObject();
xtcImageObject.setBitmap(BitmapFactory.decodeResource(getResources(), R.mipmap.img_show));
//If the image is in a public directory, you can set the image path directly

xtcImageObject.setImagePath(“filePath”);

//Step 2: Create an object of XTCShareMessage and set the property of shareObject to the object of xtcTextObject

XTCShareMessage xtcShareMessage = new XTCShareMessage();
xtcShareMessage.setShareObject(xtcImageObject);

//Step 3: Create an object of SendMessageToXTC.Request and set the property of message to xtcShareMessage

SendMessageToXTC.Request request = new SendMessageToXTC.Request();
request.setMessage(xtcShareMessage);

//Step 4: Create an object of ShareMessageManagr, call the method of sendRequestToXTC, and pass in the object of SendMessageToXTC.Request and AppKey

new ShareMessageManager(this).sendRequestToXTC(request, "appKey");
  • Share program type (graphic and textual types)
//Step 1: Create an object of XTCAppExtendObject

XTCAppExtendObject xtcAppExtendObject = new XTCAppExtendObject();
//Set the start page for click-to-share content

xtcAppExtendObject.setStartActivity(MainActivity.class.getName());
//Set the shared extension information so that clicking on shared content will bring the extension information to the jump page

xtcAppExtendObject.setExtInfo("ExtendInfo");

//Step 2: Create an object of XTCShareMessage and set the property of shareObject to the object of xtcTextObject.

XTCShareMessage xtcShareMessage = new XTCShareMessage();
xtcShareMessage.setShareObject(xtcAppExtendObject);
//Set picture

xtcShareMessage.setThumbImage(BitmapFactory.decodeResource(getResources(), R.mipmap.img_app));
//Set text

xtcShareMessage.setDescription("This is graphic textual sharing information.
");

//Step 3: Create an object of SendMessageToXTC.Request and set the property of message to xtcShareMessage

SendMessageToXTC.Request request = new SendMessageToXTC.Request();
request.setMessage(xtcShareMessage);

//Step 4: Create an object of ShareMessageManagr, call the method of sendRequestToXTC, and pass in the object of SendMessageToXTC.Request and AppKey

new ShareMessageManager(this).sendRequestToXTC(request, "appKey");

# 2.4 Share callback

//Step 1: Implement the interface of IResponseCallback

public class MainActivity extends Activity implements IResponseCallback{...}

//Step 2: Handle callbacks in the methods of onCreate and onNewIntent

private IXTCCallback xtcCallback;
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    //Handling callbacks

    xtcCallback = new XTCCallbackImpl();
    xtcCallback.handleIntent(getIntent(), this);
}
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    setIntent(intent);

    //Handling callbacks

    xtcCallback.handleIntent(intent, this);
}

//Step 3: implement the methods of onResp and onReq

public void onResp(boolean isSuccess, BaseResponse response) {
    //to-do
}
public void onReq(ShowMessageFromXTC.Request request) {
    //to-do
}
  • onResp method

This method is a callback for sharing result information after being used to click share.

Field Description
isSuccess Determining whether sharing was successful
response.getCode() Callback status code, which can be determined by BaseResponse.Code
response.getErrorDesc() Description of status code
response.getConversationId() The shared session ID of the friend circle is -1, which is returned after the session ID of the chat has been encrypted
response.getTransaction() Unique logo sharing
  • onReq method

This method is a callback which can jump to the specified page after being used to click on the shared program information in the chat or friend circle.

Field Description
request.getExtInfo() The extInfo attribute of the XTCAppExtendObject object setting
request.getScene() The shared scene, scene.getType() determines the scene type: Scene.TYPE_CHAT is chat and Scene.TYPE_MOMENT is friend circle.
request.getTransaction() Unique logo sharing

# 2.5 Sharing in specific channels

image

In addition to jumping to a channel selection page (see figure above), after the above click share, it can also jump to the channel selection page and share directly to the specified channel. The detailed method is as follows:

  • Share to chat
//Step 1: Create a scene

Chat chat = new Chat();
//If the session is not allowed to be displayed, set the default status as friends and friend groups

chat.setFriendType(Chat.FRIEND|Chat.FRIEND_GROUP);
//For friends who need to be filtered, pass in the list of coveragesId (conversitionId comes from the onReq method)

chat.setFilterConversationList(filterConversationList);
//Filter machine-type

chat.setFilterModeList(filterModeList)
//Clicking filtered-friends requires the text content of Toast

chat.setFilterTip(context.getString(R.string.share_error_limit));

//Step 2: Set the scene into the object of SendMessageToXTC.Request

SendMessageToXTC.Request request = new SendMessageToXTC.Request();
request.setScene(chat);
  • Share to friend circle
//Step 1: Create a scene

Moment moment = new Moment();

//Step 2: Set the scene to the object of SendMessageToXTC.Request

SendMessageToXTC.Request request = new SendMessageToXTC.Request();
request.setScene(moment );

# 2.6 Precautions

  • For a new ShareMessageManager (context), the context must be an activity.
  • Try to use the 8-bit icon for the application icon, or else the compressed icon will be too large and take up excessive server resources.

# 2.7 To-be supported Features

  • Photography by camera, acquisition of album

  • Push

  • Step

  • Locate

  • Video recording

  • Carrying out activities to consume points

Last Updated: 9/19/2019, 5:27:10 PM