android中facebook的点击事件
嗨,在我的android phonegap应用程序中,我使用create chooser从手机上获取所有共享应用程序。它工作正常,但我需要为facebook调用单独的意图。因此我需要从对话框中单击facebook事件 这是我的密码:android中facebook的点击事件,android,cordova,Android,Cordova,嗨,在我的android phonegap应用程序中,我使用create chooser从手机上获取所有共享应用程序。它工作正常,但我需要为facebook调用单独的意图。因此我需要从对话框中单击facebook事件 这是我的密码: Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType("text/plain"); emailIntent.putExtra(
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("text/plain");
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject );
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,"www.google.com");
this.ctx.startActivity(Intent.createChooser(emailIntent, "Share"));
请引导我。提前谢谢。试试这个:
try {
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
String[] recipients = new String[]{"e-mail address"};
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, recipients);
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "E-mail subject");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "E-mail text");
emailIntent.setType("plain/text"); // This is incorrect MIME, but Gmail is one of the only apps that responds to it - this might need to be replaced with text/plain for Facebook
final PackageManager pm = getPackageManager();
final List<ResolveInfo> matches = pm.queryIntentActivities(emailIntent, 0);
ResolveInfo best = null;
for (final ResolveInfo info : matches)
if (info.activityInfo.packageName.endsWith(".gm") ||
info.activityInfo.name.toLowerCase().contains("gmail")) best = info;
if (best != null)
emailIntent.setClassName(best.activityInfo.packageName, best.activityInfo.name);
startActivity(emailIntent);
} catch (Exception e) {
Toast.makeText(this, "Application not found", Toast.LENGTH_SHORT).show();
}
@ricintech..谢谢你的回复。你的代码我将直接移动到电子邮件。但是我需要获得所有共享应用程序的对话框。从那里我需要单击电子邮件。请引导我。确定你想显示一段对话。。。将所有应用程序名称作为项目。是的,如果我使用createchooser,它会自动打开以应用程序名称作为项目的对话框,并且它本身正在共享。但我需要在自己的facebook中使用单独的单击事件。请指导我。使用此链接:
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, "The status update text");
startActivity(Intent.createChooser(intent, "Dialog title text"));