【问题标题】:how to open facebook app on imageview Click event?如何在 imageview Click 事件上打开 Facebook 应用程序?
【发布时间】:2019-06-21 03:39:59
【问题描述】:

我想在我的应用程序中打开 Facebook 应用程序,它将显示在 Imageview On click 事件上。 我已经推荐了 10-20 个链接,尝试了所有这些链接,但对我没有任何作用。 我不想使用 Facebook 默认图片按钮,我想在 imageview 点击事件上做。

我已经尝试过链接:

还有更多

在尝试了所有我当前的代码之后:

 public void shareFacebook() {
    String fullUrl = "https://m.facebook.com";
    try {
        Intent sharingIntent = new Intent(Intent.ACTION_SEND);
        sharingIntent.setPackage ("com.facebook.katana");
        sharingIntent.putExtra(Intent.EXTRA_TEXT, "your title text");
        context.startActivity(sharingIntent);

    } catch (Exception e) {
        Intent i = new Intent(Intent.ACTION_VIEW);
        i.setData(Uri.parse(fullUrl));
        context.startActivity(i);

    }
}

清单.xml

<meta-data android:name="com.facebook.sdk.ApplicationId"
        android:value="1975812626048291"/>
    <provider
        android:name="com.facebook.FacebookContentProvider"
    android:authorities="com.facebook.app.FacebookContentProvider1975812626048291"
    android:exported="true" />
    <activity android:name="com.facebook.FacebookActivity"
        android:configChanges=
            "keyboard|keyboardHidden|screenLayout|screenSize|orientation"
        android:label="@string/app_name" />
    <activity android:theme="@style/AppTheme" android:name="com.facebook.katana.FacebookLoginActivity"
        android:permission="com.facebook.permission.prod.FB_APP_COMMUNICATION" android:exported="false"
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize" android:windowSoftInputMode="stateHidden|adjustResize" />

依赖关系

 implementation 'com.facebook.android:facebook-login:4.33.0'

显示版本应与回收站视图版本相同,但放置相同版本仍无法正常工作。

 jcenter()
    mavenCentral()
    maven { url 'https://jitpack.io'}

描述正确的实现方式,并且我已经将该 imageview 放在 recyclerview 上,所以无论你建议它应该放在 recyclerview 的 onBindViewHolder() 上。

当前的错误是:

找不到明确的活动类{com.facebook.katana/com.facebook.katana.ShareLinkActivity}; have you declared this activity in your AndroidManifest.xml?

我不知道如何在清单中描述 facebook 的活动 .. 我们是否需要另一个 java 活动来在我们的应用程序中打开应用程序?

【问题讨论】:

标签: android android-imageview facebook-apps


【解决方案1】:

在不使用 facebook SDK 的情况下打开 FB App 这是我对这个问题的要求

参考链接

Share image and text through Whatsapp or Facebook

 Intent FBIntent = new Intent(Intent.ACTION_SEND);
    FBIntent.setType("text/plain");
    FBIntent.setPackage("com.facebook.katana");
    FBIntent.putExtra(Intent.EXTRA_TEXT, "The text you wanted to share");
    try {
        context.startActivity(FBIntent);
    } catch (android.content.ActivityNotFoundException ex) {
        Toast.makeText(context, "Facebook have not been installed.", Toast.LENGTH_SHORT).show( );
    }

适用于 instagram,twitter 也可以,只需要更改包名称。

【讨论】:

    【解决方案2】:

    我认为问题在于您没有 setType。 试试这个例子。

    Intent sharingIntent = new Intent(Intent.ACTION_SEND);
        sharingIntent.setType("text/plain");
        sharingIntent.putExtra(Intent.EXTRA_SUBJECT, "Subject");
        sharingIntent.putExtra(Intent.EXTRA_TEXT, "Text...");
        sharingIntent.setPackage("com.facebook.katana");
        startActivity(sharingIntent);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-05-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多