Skip to content

Commit

Permalink
added URL Parser for sharing option.
Browse files Browse the repository at this point in the history
  • Loading branch information
kevmeyer committed Nov 16, 2014
1 parent 22265ff commit c927290
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion app/src/main/java/fr/gaulupeau/apps/Poche/Poche.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import android.os.Bundle;
import android.provider.Browser;
import android.util.Base64;
import android.util.Patterns;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
Expand All @@ -45,6 +46,8 @@
import java.security.SecureRandom;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
Expand Down Expand Up @@ -101,7 +104,22 @@ public void onCreate(Bundle savedInstanceState) {
findViewById(R.id.btnSync).setVisibility(View.GONE);
findViewById(R.id.btnGetPost).setVisibility(View.GONE);
findViewById(R.id.progressBar1).setVisibility(View.VISIBLE);
final String pageUrl = extras.getString("android.intent.extra.TEXT");



final String extraText = extras.getString("android.intent.extra.TEXT");
final String pageUrl;

// Parsing string for urls.
Matcher matcher = Patterns.WEB_URL.matcher(extraText);
if (matcher.find()) {
pageUrl = matcher.group();
} else {
showErrorMessage("Couldn't find a URL in share string:\n"+extraText);
return;
}


// Vérification de la connectivité Internet
final ConnectivityManager conMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
final NetworkInfo activeNetwork = conMgr.getActiveNetworkInfo();
Expand Down

0 comments on commit c927290

Please sign in to comment.