进一步区分启动、打开、分享(2种类型)
This commit is contained in:
@@ -16,6 +16,7 @@ import java.net.HttpURLConnection;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.net.URLDecoder;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -1578,15 +1579,32 @@ public class MainActivity extends Activity {
|
||||
}
|
||||
|
||||
void getDataFromIntent(Intent intent) {
|
||||
String type = intent.getType();
|
||||
if (type != null && type.startsWith("text/") && intent.getAction().equals(Intent.ACTION_SEND)) {
|
||||
urln = intent.getStringExtra(Intent.EXTRA_TEXT);
|
||||
if (urln.contains("\n"))
|
||||
urln = urln.substring(urln.indexOf("\n") + 1);
|
||||
newWindow(urln);
|
||||
} else if (list_webView.size() == 0){
|
||||
if (intent.getAction().equals(Intent.ACTION_VIEW)) {
|
||||
urln = intent.getDataString();
|
||||
if (urln != null) {
|
||||
if (urln.contains("\n"))
|
||||
urln = urln.substring(urln.indexOf("\n") + 1);
|
||||
newWindow(urln);
|
||||
}
|
||||
} else if (intent.getAction().equals(Intent.ACTION_SEND)) {
|
||||
Uri uri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
|
||||
if (uri != null) {
|
||||
try {
|
||||
urln = URLDecoder.decode(uri.toString(), "UTF-8");
|
||||
} catch (Exception e) {
|
||||
Log.e(Thread.currentThread().getStackTrace()[2] + "", e.toString());
|
||||
}
|
||||
} else {
|
||||
urln = intent.getStringExtra(Intent.EXTRA_TEXT);
|
||||
}
|
||||
if (urln != null) {
|
||||
if (urln.contains("\n"))
|
||||
urln = urln.substring(urln.indexOf("\n") + 1);
|
||||
newWindow(urln);
|
||||
}
|
||||
} else if (intent.getCategories().contains(Intent.CATEGORY_LAUNCHER) && list_webView.isEmpty()) {
|
||||
String surl = sharedPreferences.getString("homepage", "file:///android_asset/home.htm");
|
||||
if (surl.equals(""))
|
||||
if (surl.isEmpty())
|
||||
surl = "file:///android_asset/home.htm";
|
||||
newWindow(surl);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user