本文介绍了Android facebook意图通过类com.facebook.katana.ProfileTabHostActivity显示配置文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

天前,为了向我的用户显示另一个用户配置文件,我使用以下解决方案:

  Intent intent = new Intent(Intent .ACTION_VIEW); 
intent.setClassName(com.facebook.katana,com.facebook.katana.ProfileTabHostActivity);
Long uid = new Long(123456789);
intent.putExtra(extra_user_id,uid);
startActivity(intent);

这个解决方案被很多stackoverflow用户使用(从看到关于这个的所有问题和答案主题)。



最后一个Facebook应用更新(1.9.11),甚至可能使此解决方案过时。
现在你会得到以下例外:

以下列方式在清单中描述:

 < activity android:theme = @ style / Theme.Facebook
android:name =com.facebook.katana.ProfileTabHostActivity
android:configChanges =keyboard | keyboardHidden | orientation | screenLayout
android:windowSoftInputMode = adjustPan/>

由于此活动不再有意向过滤器的默认值的 android:exports 现在是 。在以前的版本中,有意图过滤器,然后默认值为 true (欢迎您阅读)我要感谢有关导出值的详细信息。



但新版本具有以下活动:

 < activity android:name =com.facebook.katana.IntentUriHandler> 
< intent-filter>
< action android:name =android.intent.action.VIEW/>
< category android:name =android.intent.category.DEFAULT/>
< data android:scheme =facebook/>
< / intent-filter>
< intent-filter>
< action android:name =android.intent.action.VIEW/>
< category android:name =android.intent.category.DEFAULT/>
< category android:name =android.intent.category.BROWSABLE/>
< data android:scheme =fb/>
< / intent-filter>
< / activity>

在这里,您可以看到他们支持 fb Facebook scheme。


Till few days ago, in order to show to my users another user profile I used the following solution:

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setClassName("com.facebook.katana", "com.facebook.katana.ProfileTabHostActivity");
Long uid = new Long("123456789");
intent.putExtra("extra_user_id", uid);
startActivity(intent);

This solution is used by a lot of the stackoverflow users (From seeing all the questions and answers about this subject).

The last facebook app update (1.9.11), maybe even before made this solution obsolete.Now you will get the following exception for doing so:

Does anyone know how can I now open the facebook app?

Thanks

解决方案

The solution described in the question won't work anymore (In the edit of this question you can see the details why). The new version of the facebook app doesn't support anymore those kind of intents. See here the bug report

The new solution is to use the iPhone scheme mechanism (Yes, facebook decided to support the iPhone mechanism in Android instead of the implicit intent mechanism of Android).

So in order to open the facebook app with a user profile all you need to do is:

String facebookScheme = "fb://profile/" + facebookId;
Intent facebookIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(facebookScheme)); 
startActivity(facebookIntent);

If you are looking for other actions you can use the following page for all available actions (you have to test it though, since I didn't find an official publication of facebook about this)

EDIT

This part of the question is giving more details about the nature of the problem and solution, but the details above are enough in order to solve the problem.

With the new version of the facebook app, the manifest file was changed.Today the activity

described in the manifest in the following way:

<activity android:theme="@style/Theme.Facebook"
android:name="com.facebook.katana.ProfileTabHostActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout"
android:windowSoftInputMode="adjustPan" />

Since there is no intent-filter anymore for this activity the default value of android:exported is now false. In the previous versions, there was intent-filter and then the default value was true (You are welcome to read about it here) I would like to thank this answer for the details about the exported value.

But the new version have the following activity:

<activity android:name="com.facebook.katana.IntentUriHandler">
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:scheme="facebook" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:scheme="fb" />
        </intent-filter>
    </activity>

And here you can see that they support the fb and facebook scheme.

这篇关于Android facebook意图通过类com.facebook.katana.ProfileTabHostActivity显示配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 07:00