使用示例,我找到了地图api的android:name
属性
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="your_api_key"/>
现在我正在尝试使用calandar api,到目前为止我还没有成功。我不确定我应该在这里使用的android:name
值。
<meta-data
android:name="com.google.android.calendar.v3.API_KEY"<!-- the value ?-->
android:value="your_api_key"/>
回应:
"code": 403,
"errors": [
{
"domain": "usageLimits",
"message": "Access Not Configured",
"reason": "accessNotConfigured"
}
],
"message": "Access Not Configured"
}
任何人都知道我还需要做些什么才能正确配置?
调用google api:CalendarList feed = client.calendarList()。list()。setFields(CalendarInfo.FEED_FIELDS).execute();
//Traffic Reports for API Project
Total requests
2
Requests/day
2 peak 0.07 average
Start Date
Jun 12, 2013
解决它:
Manifest.xml
<application ... >
<meta-data
android:name="com.google.android.calendar.v3.API_KEY"
android:value="your api key"/>
....
</application>
Google API访问权限:https://code.google.com/apis/console 1.如果你调试,需要添加一个应用程序,安装客户端ID 应用程序:证书指纹(SHA1):“keytool -list -v -keystore~ / .android / debug.keystore输入密码:android“ 2.应用类型:Android 3.查找API KEY:简单的API访问 - &gt;浏览器应用的密钥(带有 引用者) - &gt; API密钥:dhjkl..hjkl 4.查找产品名称:品牌信息 - &gt;产品名称
然后调用API:
final HttpTransport transport = AndroidHttp.newCompatibleTransport();
final JsonFactory jsonFactory = new GsonFactory();
GoogleAccountCredential credential;
credential =
GoogleAccountCredential.usingOAuth2(getActivity(),
Collections.singleton(CalendarScopes.CALENDAR_READONLY));
credential.setSelectedAccountName("myAccount");
client = new com.google.api.services.calendar.Calendar.Builder(
transport, jsonFactory, credential).setApplicationName("myAppName")
.build();
...
checkGooglePlayStatus()
...
...
//doInBackground()
CalendarList feed = client.calendarList().list().setFields(CalendarInfo.FEED_FIELDS).execute();
...
答案 0 :(得分:1)
您不必在清单中提供仅适用于Android版Google地图的任何内容。
如果您尝试使用Calendar API v3(https://developers.google.com/google-apps/calendar/),则首先需要使用OAuth 2进行身份验证。
以下是Google网站上有关如何在Android https://code.google.com/p/google-api-java-client/wiki/OAuth2#Android上使用Calendar API v3的示例