我需要授予用户选择预安装在手机Messenger(SMS,Mail,Viber,WhatsApp,Skype等)上的功能,并随其发送文本消息。
在Android和iOS上是否有没有自定义视图的方法?仅可以找到通过特定应用程序发送消息的方法。
答案 0 :(得分:1)
String txt = "text to share";
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Subject");
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, txt);
startActivity(Intent.createChooser(sharingIntent, getResources().getString(R.string.share)));
答案 1 :(得分:0)
感谢,LifeStyle。还有Xamain的最终实现:
[iOS]
public void Send(string message)
{
var activityItems = new[] { NSObject.FromObject(message) };
var activity = new UIActivityViewController(activityItems, null);
UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController(activity, true, null);
}
[Android]
public void Send(string message)
{
var intent = new Intent(Intent.ActionSend);
intent.SetType("text/plain");
intent.PutExtra(Intent.ExtraSubject, "Subj");
intent.PutExtra(Intent.ExtraText, message);
_targetActivity.StartActivityForResult(Intent.CreateChooser(intent, "Title"), _resultCode);
}