Java 为什么我的gcm仅为同一应用程序授权我的设备注册id?

Java 为什么我的gcm仅为同一应用程序授权我的设备注册id?,java,android,google-cloud-messaging,Java,Android,Google Cloud Messaging,我试图通过生成json数组并作为http发送,通过java代码发送gcm推送消息 我有同一个应用程序中不同设备的注册ID数组。 问题: 问题是,每当我将gcm消息发送到注册id数组时,我只会收到发送消息的同一注册id(设备)的成功消息,而对于其他id,则在我从gcm返回的消息中显示无效注册id错误 应用程序仅验证我自己的注册id!为什么? 请尽量给我提供一些信息。那是api密钥吗 私有void sendPush(ArrayList RegistrationId,字符串消息)引发异常{ HttpP

我试图通过生成json数组并作为http发送,通过java代码发送gcm推送消息

我有同一个应用程序中不同设备的注册ID数组。 问题: 问题是,每当我将gcm消息发送到注册id数组时,我只会收到发送消息的同一注册id(设备)的成功消息,而对于其他id,则在我从gcm返回的消息中显示无效注册id错误

应用程序仅验证我自己的注册id!为什么? 请尽量给我提供一些信息。那是api密钥吗

私有void sendPush(ArrayList RegistrationId,字符串消息)引发异常{

HttpPost HttpPost=新的HttpPost(“”)

httppost.addHeader(“授权”、“key=“key”);
addHeader(“内容类型”、“应用程序/json”);
JSONObject toObject=新的JSONObject();
JSONObject dataObject=新的JSONObject();
dataObject.put(“msg”,消息);
dataObject.put(“标题”、“测试标题”);
toObject.put(“数据”,数据对象);
JSONArray arObject=新的JSONArray();

对于(int i=0;如果您从何处获得其他注册id???其他注册id我正在从服务器数据库同步到android本地数据库!!这些注册id是我在登录时使用同一应用程序生成的,我还认为它获得了正确的注册id格式..当设备向同一设备注册id发送消息时仅..如果注册ID不正确,则不应将其发送到同一设备,但对于我已检查过的所有设备,它将发送到自身。:(对于单个设备,只有一个id是有效的。因此,代码中没有错误。如果您想要更多注册id,请使用Google API创建更多模拟器,然后注册这些。我有两个设备,我已经为这两个设备注册了,在数据库中,我现在有两个不同的注册id,但应用程序只向注册id发送消息。)与自己的
httppost.addHeader("Authorization", "key="key");
httppost.addHeader("Content-Type", "application/json");

JSONObject topObject=new JSONObject();


JSONObject dataObject=new JSONObject();
dataObject.put("msg", message);
dataObject.put("title", "Test Title");

topObject.put("data", dataObject);

JSONArray arObject=new JSONArray();



for(int i=0;i<registrationids.size();i++)
{
arObject.put(registrationids.get(i));
Log.e("", registrationids.get(i)+"");
}

//arObject.put(registrationids.get(1));


topObject.put("registration_ids", arObject);

String jsonBody=topObject.toString();
httppost.setEntity(new StringEntity(jsonBody,"UTF-8"));





HttpClient httpclient = new DefaultHttpClient();
HttpResponse httpResponse = httpclient.execute(httppost);
HttpEntity resEntity = httpResponse.getEntity();

// Get the HTTP Status Code
int statusCode = httpResponse.getStatusLine().getStatusCode();

// Get the contents of the response
InputStream input = resEntity.getContent();
String responseBody = Utils.convertStreamToString(input);
input.close();

// Print the response code and message body
Log.e("HTTP Status Code:", statusCode+"");
Log.e("responseBody", responseBody);