修复无法接收分享的问题
This commit is contained in:
@@ -142,7 +142,7 @@ public class MainActivity extends Activity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (Build.VERSION.SDK_INT >= 23) {
|
||||
//Log.e(Thread.currentThread().getStackTrace()[2] + "", "checkSelfPermission: " + checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE));
|
||||
if (checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED && checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED && checkSelfPermission(Manifest.permission.INSTALL_SHORTCUT) != PackageManager.PERMISSION_GRANTED) {
|
||||
requestPermissions(PERMISSIONS, REQUEST_PERMISSION_CODE);
|
||||
@@ -1001,7 +1001,7 @@ public class MainActivity extends Activity {
|
||||
webView.loadUrl(js);
|
||||
break;
|
||||
case 22:
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
if (Build.VERSION.SDK_INT >= 26) {
|
||||
layout = new LinearLayout(MainActivity.this);
|
||||
layout.setOrientation(LinearLayout.VERTICAL);
|
||||
final EditText editText_title1 = new EditText(MainActivity.this);
|
||||
@@ -1316,8 +1316,10 @@ public class MainActivity extends Activity {
|
||||
void newWindow(String surl) {
|
||||
WebView webView = new WebView(MainActivity.this);
|
||||
settingWebView(webView);
|
||||
if (!surl.equals(""))
|
||||
if (surl.contains("://"))
|
||||
webView.loadUrl(surl);
|
||||
else
|
||||
webView.loadUrl("https://www.baidu.com/s?wd=" + surl);
|
||||
webViewLayout.removeAllViews();
|
||||
webViewLayout.addView(webView);
|
||||
list_webView.add(webView);
|
||||
@@ -1330,7 +1332,7 @@ public class MainActivity extends Activity {
|
||||
void settingWebView(WebView webView) {
|
||||
registerForContextMenu(webView); // 注册菜单
|
||||
webView.requestFocusFromTouch(); // 请求触摸焦点
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
if (Build.VERSION.SDK_INT >= 19) {
|
||||
webView.setWebContentsDebuggingEnabled(true); // 允许调试
|
||||
}
|
||||
|
||||
@@ -1576,10 +1578,11 @@ public class MainActivity extends Activity {
|
||||
}
|
||||
|
||||
void getDataFromIntent(Intent intent) {
|
||||
//Log.e(Thread.currentThread().getStackTrace()[2] + "", "intent(" + intent + ")");
|
||||
if (list_webView.size() != 0 && intent.hasCategory(Intent.CATEGORY_LAUNCHER)) return;
|
||||
if (intent.getAction().equals(Intent.ACTION_VIEW)) {
|
||||
urln = intent.getDataString();
|
||||
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 {
|
||||
String surl = sharedPreferences.getString("homepage", "file:///android_asset/home.htm");
|
||||
|
||||
Reference in New Issue
Block a user