小编sal*_*lai的帖子

使Webview内容适合屏幕

我有一个从本地资产文件夹加载网站的webview:

    webView = (WebView) findViewById(R.id.webView);

    //webView.setInitialScale(1);
    //webView.getSettings().setDefaultZoom(WebSettings.ZoomDensity.FAR);
    //webView.getSettings().setLoadWithOverviewMode(true);
    //webView.getSettings().setUseWideViewPort(true);

    webView.getSettings().setJavaScriptEnabled(true);
    webView.getSettings().setDomStorageEnabled(true);

    webView.setWebViewClient(new WebViewClient() {

        public void onPageFinished(WebView view, String url) {
            webView.setVisibility(View.VISIBLE);
        }
    });

    if ((Locale.getDefault().getLanguage()).contains("ar"))
        webView.loadUrl("file:///android_asset/Index-ar.html");
    else
        webView.loadUrl("file:///android_asset/Index-en.html");
Run Code Online (Sandbox Code Playgroud)

默认情况下,网页被放大,用户必须滚动,我想要的是将页面宽度调整到webview宽度(全屏).

评论向您展示了我的尝试:

setInitialScale(1) 隐藏页面的所有内容!

setDefaultZoom(WebSettings.ZoomDensity.FAR) 一无所获.

setLoadWithOverviewMode(true)setUseWideViewPort(true)缩小到很多.

有什么建议 ?

android zoom webview

2
推荐指数
1
解决办法
6545
查看次数

无法使用 Intent.FLAG_ACTIVITY_NEW_TASK

我有一个警报项目,AlarmReceiver我有这个代码。

错误是标志无法使用,Android Studio 说 FLAG_ACTIVITY_NEW_TASK 未列在可用的意图标志中。

如何解决?

http://i.stack.imgur.com/vbpLs.png

java android

2
推荐指数
1
解决办法
1686
查看次数

无法连接到graph.facebook.com端口443:连接被拒绝

我是FB图形API的新手,我尝试在我的网站中包含FB登录,我从他们的网站上关注官方FB登录教程,但登录后我收到以下错误:

Failed to connect to graph.facebook.com port 443: Connection refused
Run Code Online (Sandbox Code Playgroud)

的login.php

<?php
session_start();
require_once __DIR__ . '/fbsdk/src/Facebook/autoload.php';

$fb = new Facebook\Facebook([
'app_id' => 'xxx',
'app_secret' => 'xxx',
'default_graph_version' => 'v2.3',
// . . .
]);

$helper = $fb->getRedirectLoginHelper();
$permissions = ['public_profile', 'email']; // optional
$loginUrl = $helper->getLoginUrl('http://-myserver-/login-callback.php',    $permissions);

echo '<a href="' . $loginUrl . '">Log in with Facebook!</a>';
?>
Run Code Online (Sandbox Code Playgroud)

登录-callback.php

<?php
session_start();
require_once __DIR__ . '/fbsdk/src/Facebook/autoload.php';

$fb = new Facebook\Facebook([
'app_id' => 'xxx',
'app_secret' => 'xxx',
'default_graph_version' => 'v2.3',
// …
Run Code Online (Sandbox Code Playgroud)

php facebook facebook-graph-api

2
推荐指数
1
解决办法
4953
查看次数

文件选择器无法过滤和选择 intent.setType("application/excel")

我正在开发一个使用 apache poi 读取/写入 excel 文件的 android 应用程序。为了从文件系统中选择一个文件,我使用了以下代码

private void showFileChooser() {
    Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.setType("application/excel");
    intent.addCategory(Intent.CATEGORY_OPENABLE);

    try {
        startActivityForResult(
                Intent.createChooser(intent, "Select a File to Upload"),
                FILE_SELECT_CODE);
    } catch (android.content.ActivityNotFoundException ex) {
        // Potentially direct the user to the Market with a Dialog
        Toast.makeText(this, "Please install a File Manager.",
                Toast.LENGTH_SHORT).show();
    }
}
Run Code Online (Sandbox Code Playgroud)

该行intent.setType("application/excel");用于过滤excel文件。但android文件管理器不选择任何excel文件。它保持在禁用阶段。我通过替换intent.setType("application/excel");intent.setType("file/.mp3");它来检查此代码它工作正常并且它选择 mp3 文件。我也试过intent.setType("file/.xls");没有运气。

java excel android android-intent

1
推荐指数
1
解决办法
1285
查看次数