Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import android.content.Context;

import android.preference.PreferenceManager;

public class Main {
    public static String getParakeetSetupURL(Context context) {
        String url = getParakeetURL(context);
        if (url == null)
            return null;
        return url.replace("/json.get", "/setcode/2");
    }

    public static String getParakeetURL(Context context) {
        String my_receivers = PreferenceManager.getDefaultSharedPreferences(context)
                .getString("wifi_recievers_addresses", "").trim();
        if (my_receivers.equals(""))
            return null;

        String[] hosts = my_receivers.split(",");
        if (hosts.length == 0)
            return null;

        for (String host : hosts) {
            host = host.trim();
            if ((host.startsWith("http://") || host.startsWith("https://"))
                    && (host.contains("/json.get") || host.contains("Parakeet"))) {
                return host;
            }
        }
        return null;
    }
}