Android的:如何让应用程序的名称为我们的TextView应用程序、名称、Android、TextView

由网友(聚散不由人)分享简介:我有一个 DialogBox的与的TextView ,假设我的应用程序MyFriendsSecrets..I我发送一个职位我的应用程序,如何让我的应用程序名称到的TextView (例如:从上面PIC:通过MyFriendSecrets)任何建议是AP preciated。我有一个 JSON OBJ如下I h...

我有一个 DialogBox的的TextView ,假设我的应用程序MyFriendsSecrets..I我发送一个职位我的应用程序,如何让我的应用程序名称到的TextView (例如:从上面PIC:通过MyFriendSecrets) 任何建议是AP preciated。我有一个 JSON OBJ如下

I have a DialogBox with a TextView,suppose my app is MyFriendsSecrets..I am sending a post from my app, how to get my Application name into the TextView ( example: from above pic: "via MyFriendSecrets") Any suggestions is appreciated. i have a JSON obj as below

JSONObject的我=新的JSONObject(facebook.request(我));

JSONObject me = new JSONObject(facebook.request("me"));

推荐答案

运行瞄准的申请表。既然你的工作在自己的应用程序,并有机会获得它的应用程序ID,构造这个查询将是非常容易的。

Run an FQL query targeting the application table. Since you working on your own App and will have access to it's App ID, constructing this query will be very easy.

试试这块code:

String queryApp = "SELECT display_name, namespace  FROM application WHERE app_id=284752504943219";
Bundle paramsApp = new Bundle();
paramsApp.putString("method", "fql.query");
paramsApp.putString("query", queryApp);
String resultApp = Utility.mFacebook.request(paramsApp);
Log.e("APP RESULT", resultApp);

JSONArray JAApp = new JSONArray(resultApp);

for (int i = 0; i < JAApp.length(); i++) {
    JSONObject JOApp = JAApp.getJSONObject(i);

    String getDisplayName = JOApp.getString("display_name");
    Log.e("DISPLAY NAME", getDisplayName);
}

在 DISPLAY_NAME 查询经由应用程序发布时(如图连接到OP图像)显示在Facebook将返回应用程序的名称字段。解析结果,并将其设置为您的的TextView

The display_name field in the query will return the name of the App as is shown on Facebook when posting via the App (as shown in the picture attached to the OP). Parse the result and set it to your TextView.

由于这直接查询Facebook的API,你将不必担心手工更改的字符串的,如果你是通过Facebook的开发者控制台来更改应用程序的名称。

Since this queries the Facebook API directly, you will not have to worry about manually changing strings if you were to change the name of the App via the Facebook Developer Console.

阅读全文

相关推荐

最新文章