如何强制共享意图打开特定应用程序? [英] How to force Share Intent to open a specific app?
本文介绍了如何强制共享意图打开特定应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我喜欢分享的意图,它是完美的开放共享的应用程序有图片和文字的参数。
I like share intent, it is perfect to open sharing apps with image and text parameters.
但现在我研究强迫份额的意图,从列表中打开一个特定的应用程序,与paramters给予份额意图的方式。
But now i'm researching the way to force share intent to open a specific app from the list, with the paramters given to the share intent.
这是我的实际code,它显示在手机上安装的共享应用程序列表。请,可somedone告诉我,我应该加入到code强制例如官方Twitter的应用程序?和官方faccebok的应用程序?
This is my actual code, it shows the list of sharing apps installed on the phone. Please, can somedone tell me what i should add to the code to force for example official twitter app? and official faccebok app?
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
Uri screenshotUri = Uri.parse("file:///sdcard/test.jpg");
sharingIntent.setType("image/*");
sharingIntent.putExtra(Intent.EXTRA_TEXT, "body text");
sharingIntent.putExtra(Intent.EXTRA_STREAM, screenshotUri);
startActivity(Intent.createChooser(sharingIntent, "Share image using"));
感谢
推荐答案
有关Facebook的
For Facebook
public void shareFacebook() {
String fullUrl = "https://m.facebook.com/sharer.php?u=..";
try {
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
sharingIntent.setClassName("com.facebook.katana",
"com.facebook.katana.ShareLinkActivity");
sharingIntent.putExtra(Intent.EXTRA_TEXT, "your title text");
startActivity(sharingIntent);
} catch (Exception e) {
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(fullUrl));
startActivity(i);
}
}
有关Twitter的。
For Twitter.
public void shareTwitter() {
String message = "Your message to post";
try {
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
sharingIntent.setClassName("com.twitter.android","com.twitter.android.PostActivity");
sharingIntent.putExtra(Intent.EXTRA_TEXT, message);
startActivity(sharingIntent);
} catch (Exception e) {
Log.e("In Exception", "Comes here");
Intent i = new Intent();
i.putExtra(Intent.EXTRA_TEXT, message);
i.setAction(Intent.ACTION_VIEW);
i.setData(Uri.parse("https://mobile.twitter.com/compose/tweet"));
startActivity(i);
}
}
这篇关于如何强制共享意图打开特定应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文