nhe*_*nn1 5 android facebook android-intent
可能重复:
从其他应用程序启动Facebook应用程序
几天前,为了向我的用户展示另一个用户配置文件,我使用了以下解决方案:
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);
Run Code Online (Sandbox Code Playgroud)
许多stackoverflow用户都使用此解决方案(从查看有关此主题的所有问题和答案).
最后的Facebook应用更新(1.9.11),甚至可能在此解决方案过时之前.现在,您将收到以下异常:
java.lang.SecurityException:Permission Denial:从ProcessRecord启动Intent {act = android.intent.action.VIEW cmp = com.facebook.katana/.ProfileTabHostActivity(has extras)} ...需要null
有谁知道我现在如何打开Facebook应用程序?
谢谢
nhe*_*nn1 12
问题中描述的解决方案将不再起作用(在编辑此问题时,您可以看到详细信息).Facebook应用程序的新版本不再支持那种意图了.见这里的bug报告
新的解决方案是使用iPhone方案机制(是的,facebook决定在Android中支持iPhone机制而不是Android的隐式意图机制).
因此,要使用用户个人资料打开Facebook应用,您需要做的就是:
String facebookScheme = "fb://profile/" + facebookId;
Intent facebookIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(facebookScheme));
startActivity(facebookIntent);
Run Code Online (Sandbox Code Playgroud)
如果您正在寻找其他操作,您可以使用以下页面进行所有可用的操作(您必须测试它,因为我没有找到facebook的官方出版物)
这部分问题是提供有关问题和解决方案性质的更多细节,但上述细节足以解决问题.
使用新版本的facebook应用程序,清单文件已更改.今天的活动
com.facebook.katana.ProfileTabHostActivity
通过以下方式在清单中描述:
<activity android:theme="@style/Theme.Facebook"
android:name="com.facebook.katana.ProfileTabHostActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout"
android:windowSoftInputMode="adjustPan" />
Run Code Online (Sandbox Code Playgroud)
由于此活动不再有intent-filter,因此android:exported的默认值现在为false.在以前的版本中,有intent-filter,然后默认值为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>
Run Code Online (Sandbox Code Playgroud)
在这里你可以看到他们支持fb和facebook方案.
| 归档时间: |
|
| 查看次数: |
5367 次 |
| 最近记录: |