使用示例,我找到android:name
了 maps api 的属性
<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"
}
任何人都知道我还需要做什么才能正确配置它?
调用谷歌 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
解决它:
清单.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:Simple API Access --> 浏览器应用的密钥(带引用者)-->API 密钥:dhjkl..hjkl 4.查找产品名称: 品牌信息-->产品名称
然后调用 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();
...