asynctaskで奇妙な警告を受けました。GCMを学んでいるので、asynctaskを使用しようとしました。私はスレッドが、それは安全ではない.whyについては、これはそれをwarning.ISの意味を理解したいAsynctask strange behavior
Type safety: The method execute(Object...) belongs to the raw type AsyncTask. References to generic type AsyncTask<Params,Progress,Result> should be parameterized
: これは警告ですか?これは何ですか?
これは私のコードです:ジェネリックを行うには
private void registerInBackground() {
// TODO Auto-generated method stub
new AsyncTask() {
@Override
protected Object doInBackground(Object... arg0) {
// TODO Auto-generated method stub
String msg = "";
try {
if (gcm == null) {
gcm = GoogleCloudMessaging.getInstance(getApplicationContext());
}
regid = gcm.register(SENDER_ID);
msg = "Device registered, registration ID=" + regid;
// You should send the registration ID to your server over HTTP,
// so it can use GCM/HTTP or CCS to send messages to your app.
// The request to your server should be authenticated if your app
// is using accounts.
sendRegistrationIdToBackend();
// For this demo: we don't need to send it because the device
// will send upstream messages to a server that echo back the
// message using the 'from' address in the message.
// Persist the regID - no need to register again.
storeRegistrationId(getApplicationContext(), regid);
} catch (IOException ex) {
msg = "Error :" + ex.getMessage();
// If there is an error, don't just keep trying to register.
// Require the user to click a button again, or perform
// exponential back-off.
}
return msg;
} @Override
protected void onPostExecute(Object result) {
// TODO Auto-generated method stub
super.onPostExecute(result);
Toast.makeText(getApplicationContext(), ""+result.toString(), Toast.LENGTH_LONG).show();
}
}.execute(null, null, null);
}
おかげ
。 ありがとう –