Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/*
 * Copyright (C) 2015 Marten Gajda <marten@dmfs.org>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 */

import android.content.Intent;

import android.net.Uri;

public class Main {
    /**
     * global key to get url from intent extras.
     */
    public static final String EXTRAS_URL = "org.dmfs.android.cloudattach.extras.URL";

    /**
     * Extracts the {@link Uri url} out of an attachment upload. The url is part of the result {@link Intent} in {@link Activity#onActivityResult()} of a former
     * {@link #startAttachmentActivity()} call.
     * 
     * @param activityResultIntent
     *            Result {@link Intent} from {@link Activity#onActivityResult(int, int, Intent)}.
     * @return the upload url as {@link Uri} or null, if the result {@link Intent} contains no url.
     */
    public static Uri getUrlFromResult(Intent activityResultIntent) {
        Uri url = activityResultIntent.getData();
        if (url == null) {
            if (activityResultIntent.hasExtra(EXTRAS_URL)) {
                url = Uri.parse(activityResultIntent.getStringExtra(EXTRAS_URL));
            }
        }
        return url;
    }
}