Java 如何将自定义_网站设置为android应用程序
我想把我的网站添加到,但我不能。请帮帮我。如何将网站添加为我的自定义网站 当我获得上下文时,我有一个类Q2AWebsite。我想添加自定义网站到它。有谁能提供解决方案吗 这是代码-Java 如何将自定义_网站设置为android应用程序,java,android,apk,Java,Android,Apk,我想把我的网站添加到,但我不能。请帮帮我。如何将网站添加为我的自定义网站 当我获得上下文时,我有一个类Q2AWebsite。我想添加自定义网站到它。有谁能提供解决方案吗 这是代码- public class Q2AWebsite { // set this if you are hardcoding a website into your app public final static String CUSTOM_WEBSITE = null; publi
public class Q2AWebsite {
// set this if you are hardcoding a website into your app
public final static String CUSTOM_WEBSITE = null;
public static String getWebsite(Context context) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
String website = CUSTOM_WEBSITE != null ? CUSTOM_WEBSITE : prefs.getString("website", "");
if (website.length() == 0) return null;
website = sanitizeWebsite(website);
return website;
}
public static String sanitizeWebsite(String website) {
if (!website.startsWith("http")) website = "http://" + website;
// potential problems
website = website.replaceAll("\\?.*", "").replaceAll("index.php$", "");
if (!website.endsWith("/")) website = website + "/";
return website;
}
public static boolean isValidWebsite(String link) {
try {
URI.create(link);
} catch (Exception e) {
return false;
}
return true;
}
公共类网站{
// set this if you are hardcoding a website into your app
public final static String CUSTOM_WEBSITE = null;
public static String getWebsite(Context context) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
String website = CUSTOM_WEBSITE != null ? CUSTOM_WEBSITE : prefs.getString("website", "");
if (website.length() == 0) return null;
website = sanitizeWebsite(website);
return website;
}
public static String sanitizeWebsite(String website) {
if (!website.startsWith("http")) website = "http://" + website;
// potential problems
website = website.replaceAll("\\?.*", "").replaceAll("index.php$", "");
if (!website.endsWith("/")) website = website + "/";
return website;
}
public static boolean isValidWebsite(String link) {
try {
URI.create(link);
} catch (Exception e) {
return false;
}
return true;
}
不要链接您的代码。将其添加到您的问题。您可以删除此答案,因为您错误地添加了它。我已编辑了您的问题。