Search code examples
androidchatvoiceapplozic

send a voice message as attachment with applozic android


i'm working with applozic api, and i can't find in the documentation how to send a voice message as attachment.

import com.applozic.mobicomkit.api.conversation.MobiComConversationService;

 public void sendMessage(Message message)        
 {             
   ...        
 }

new MobiComConversationService(activity).sendMessage(new     
Message("[email protected]", "hello test"));


 public synchronized List<Message> getLatestMessagesGroupByPeople()        
 {            
  ...         
 }

 public List<Message> getMessages(String userId, Long startTime, Long endTime)        
 {            
  ...           
 }

Solution

  • There are two ways to send a voice message:

    1. Direct way: Create message object and set the userId whom you want to send message and set the file path of voice message file, user content Type Message.ContentType.AUDIO_MSG.getValue().

      Message message = new Message();
      message.setTo("userId");//Replace userId with user whom u want send a audio message
      List<String> filePathsList = new ArrayList<String>();
      filePathsList.add(filePath);//set the file path where the audio file is stored
      message.setFilePaths(filePathsList);
      message.setContentType(Message.ContentType.AUDIO_MSG.getValue());
      new MobiComConversationService(context).sendMessage(message);
      
    2. UI toolkit: Click attachment option icon --> select Audio --> record the voice and send voice message.

    enter image description here