Android的:如何让应用程序的名称为我们的TextView [英] Android: how to get the app name into our textview

查看:93
本文介绍了Android的:如何让应用程序的名称为我们的TextView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 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.

这篇关于Android的:如何让应用程序的名称为我们的TextView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆