Android Studio - Use Tencent Instant Messenger

Record

Customize the pop-up window in the introduced Tencent third-party plug-in

As in the title, because the project introduces the Tencent instant messaging module, but the main functions are in the app module, and the application platform review requires the reporting function in the Tencent instant messaging module, but user information and the like basically exist. app main module, so a bridge needs to be made

Solutions

1. Complete the communication between the two modules first.
I use the appjoint recommended by netizens
for reference.

https://blog.csdn.net/qq_23018457/article/details/110469916

It's very simple, it's over once, just add this module in the corresponding build.gradle, then
write an interface class, an implementation class, implement the interface in the main app module, and call the interface in the sub-module that needs to be called through reflection Method
2 How to customize
the project There is already an activity management class in the project, but the activity of Tencent Instant Messaging has not been added, so it is necessary to add the popactivity of the activity management class to the corresponding activity (my chatactivity here) method, record the current activity (in chatactivity, remember to add a method that the outside world can access the context of the current activity)
and then call the currentactivity method in the activity management class to get chatactivity, and then get its context, and add dialog on this context , and some corresponding information in it can be completed, and the time relationship is to paste a simple code.
This is the implementation class that implements the interface class in the app


@ServiceProvider
public class AppPublicInterface implements MyPublicInterface {
    
    
    @Override
    public void showJubakInfo(int type, String userTId, Object data) {
    
    


        //这里要获得消息的内容和消息的发出者的id
        //需要弹出一个确定框,让用户确认举报信息是否正确
        ChatActivity currentActivity = (ChatActivity) ActivityManager.getInstance().currentActivity();

        AlertDialog.Builder builder = new AlertDialog.Builder(currentActivity.getContext());
        builder.setTitle("举报");


        final EditText edit = new EditText(currentActivity.getContext());
        builder.setView(edit);
        if (type == 0) {
    
    
            edit.setText("举报人: " + UserInfoInstance.getInstance().getRealName() + "\n举报内容: " + data.toString());
        } else if (type == 32) {
    
    
            edit.setText("举报人: " + UserInfoInstance.getInstance().getRealName() + "\n您举报的内容为图片,请耐心等待审核结果");
        }else{
    
    
            edit.setText("举报人: " + UserInfoInstance.getInstance().getRealName() + "\n您举报的内容为未知内容,请耐心等待审核结果");
        }
        edit.setFocusable(false);
        edit.setEnabled(false);
        edit.setTextAlignment(TEXT_ALIGNMENT_CENTER);
        builder.setPositiveButton("提交", new DialogInterface.OnClickListener() {
    
    
            @Override
            public void onClick(DialogInterface dialog, int which) {
    
    
                ReportPresenter tem = new ReportPresenter();
                tem.report(userTId, data.toString());
            }
        });
        builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
    
    
            @Override
            public void onClick(DialogInterface dialog, int which) {
    
    
            }
        });
        builder.setCancelable(true);    //设置按钮是否可以按返回键取消,false则不可以取消
        AlertDialog dialog = builder.create();  //创建对话框
        dialog.setCanceledOnTouchOutside(true); //设置弹出框失去焦点是否隐藏,即点击屏蔽其它地方是否隐藏
        dialog.show();
    }
}

Guess you like

Origin blog.csdn.net/pure81/article/details/128224970