我可以通过 java 代码添加 facebook appId 而不是在清单中添加吗(API 4)
Can i add facebook appId through java code rather than add in manifest(API 4)
<provider
android:name="com.facebook.FacebookContentProvider"
android:authorities="com.facebook.app.FacebookContentProvider455621177938568"
android:exported="true" />
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="@string/facebook_app_id" />
我可以在 activity class 中初始化这些应用程序 ID 吗?
-你好
- 是的,你可以通过 Session
添加你的应用程序 ID
-这是它的示例代码:-
String appidstring="Your app id";
Session session = new Session.Builder(getBaseContext()).setApplicationId(appidstring).build();
Session.setActiveSession(session);
if (session.getState().equals(SessionState.CREATED_TOKEN_LOADED)) {
session.openForRead(new Session.OpenRequest(this).setCallback(statusCallback));
}
--------更新--------------------
-抱歉,我忘记了 facebook sdk v4 根据此文档 Upgrading from older version session class has been removed
-如果您想以编程方式设置应用程序 ID ...您可以将其设置为
FacebookSdk.setApplicationId(APP_ID);
-谢谢!
<provider
android:name="com.facebook.FacebookContentProvider"
android:authorities="com.facebook.app.FacebookContentProvider455621177938568"
android:exported="true" />
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="@string/facebook_app_id" />
我可以在 activity class 中初始化这些应用程序 ID 吗?
-你好
- 是的,你可以通过 Session
-这是它的示例代码:-
String appidstring="Your app id";
Session session = new Session.Builder(getBaseContext()).setApplicationId(appidstring).build();
Session.setActiveSession(session);
if (session.getState().equals(SessionState.CREATED_TOKEN_LOADED)) {
session.openForRead(new Session.OpenRequest(this).setCallback(statusCallback));
}
--------更新--------------------
-抱歉,我忘记了 facebook sdk v4 根据此文档 Upgrading from older version session class has been removed
-如果您想以编程方式设置应用程序 ID ...您可以将其设置为
FacebookSdk.setApplicationId(APP_ID);
-谢谢!