Back to project page demo-app-android.
The source code is released under:
MIT License
If you think the Android project demo-app-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package io.rong.imkit.demo; /*w w w . ja v a2 s.co m*/ import android.net.Uri; import android.os.Bundle; import android.os.Handler; import android.support.v4.app.FragmentActivity; import android.view.LayoutInflater; import android.view.View; import android.widget.Button; import io.rong.imkit.RongIM; import io.rong.imkit.view.ActionBar; import io.rong.imlib.RongIMClient; import io.rong.message.RichContentMessage; /** * Created by DragonJ on 14-9-15. */ public class TestFragment2Activity extends FragmentActivity { ActionBar mActionBar; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getIntent().setData(Uri.parse("rong://io.rong.imkit.demo").buildUpon().appendPath("conversation").appendPath("private") .appendQueryParameter("targetId", DemoContext.getInstance().getCurrentUser().getUserId()).appendQueryParameter("title", "??").build()); setContentView(R.layout.activity_test2_fragment); mActionBar = (ActionBar) findViewById(R.id.rc_actionbar); mActionBar.getTitleTextView().setText("??????Fragment??"); mActionBar.setOnBackClick(new View.OnClickListener() { @Override public void onClick(View v) { // finish(); sendMessage(); } }); LayoutInflater inflater = LayoutInflater.from(this); Button button = (Button) inflater.inflate(R.layout.ui_action_btn, mActionBar, false); // button.setOnClickListener(); mActionBar.addView(button); } private void sendMessage() { String content = "????????10?14?? ????????????14??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????6???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????"; String title = "????????10?14??,????????????????????????????"; String url = "http://img2.cache.netease.com/photo/0003/2014-10-15/900x600_A8J6CVA400AJ0003.jpg"; final RichContentMessage imageTextMessage = new RichContentMessage(title, content, url); imageTextMessage.setExtra("????????????????????URI,????????????????????????????"); RongIM.getInstance().sendMessage(RongIMClient.ConversationType.PRIVATE, DemoContext.getInstance().getCurrentUser().getUserId(), imageTextMessage, new RongIMClient.SendMessageCallback() { @Override public void onSuccess(int messageId) { } @Override public void onError(int messageId, ErrorCode errorCode) { } @Override public void onProgress(int messageId, int percent) { } } ); } }