@Override public boolean onStartJob(final JobParameters job) { PLog.d(ParseGCM.TAG, "Updating GCM token"); Task.callInBackground(new Callable<Void>() { @Override public Void call() { try { InstanceID instanceID = InstanceID.getInstance(getApplicationContext()); String senderId = job.getExtras().getString(KEY_GCM_SENDER_ID); String token = instanceID.getToken(senderId, GoogleCloudMessaging.INSTANCE_ID_SCOPE, null); ParseInstallation installation = ParseInstallation.getCurrentInstallation(); installation.setDeviceToken(token); //even though this is FCM, calling it gcm will work on the backend installation.setPushType(PUSH_TYPE); installation.save(); PLog.d(ParseGCM.TAG, "GCM registration success"); } catch (Exception e) { PLog.e(ParseGCM.TAG, "GCM registration failed", e); jobFinished(job, true); } return null; } }); return true; // Answers the question: "Is there still work going on?" }
for (int i = 0; i < 20; i++) { final int number = i; Task<Void> task = Task.callInBackground(new Callable<Void>() { @Override public Void call() throws Exception {
Task.callInBackground(new Callable<Void>() { @Override public Void call() {
@Override public Task<File> downloadFileAsync(final String srcUrl, final String dest) { final Capture<HttpURLConnection> urlConn = new Capture<>(); return Task.callInBackground(() -> { URL fileUrl = new URL(srcUrl); urlConn.set((HttpURLConnection) fileUrl.openConnection());
final Capture<String> content = new Capture<String>(); final Capture<String> contentType = new Capture<String>(); return Task.callInBackground(new Callable<Void>() { @Override public Void call() throws Exception {