1. Are you ready for the Galaxy S20? Here is everything we know so far!

android web view problem on loading site data

Discussion in 'Android Development' started by dherst_4, Dec 27, 2018.

  1. dherst_4

    dherst_4 Lurker
    Thread Starter

    hello

    I wrote a web viewing application

    But the problem here is with internal content like file uploads, likes, comments and ...Can not access

    But in the Chrome browser I open, I can do all this

    Can anyone help me on this?

    Even in webviewing software there is a problem
     


  2. Deleted User

    Deleted User Guest

    Moved to Android Development forum.

    You problem isn't clearly defined. Could you clarify, and add some relevant code to demonstrate the problem?
     
    GameTheory likes this.
  3. dherst_4

    dherst_4 Lurker
    Thread Starter

    i don't any problem in coding
    just For example, I open my site with a browser, similar to Chrome.
    I can browse and send post on the site



    . But in webview app, I can not access the site's internal content, such as uploading or ...
     
  4. GameTheory

    GameTheory Android Expert

    Considering you did not post any code to analyze to find the issue I'll simply just post some code from one of my old apps. Maybe this will help you, maybe it won't.

    Code (Text):
    1. private WebView webview;
    2.     String url = "https://SOME-URL.com/";
    3.     ProgressBar progress;
    4.  
    5.     @Override
    6.     @SuppressWarnings("setJavaScriptEnabled")
    7.     public void onCreate(Bundle savedInstanceState) {
    8.         super.onCreate(savedInstanceState);
    9.         setContentView(R.layout.activity_web);
    10.  
    11.         Toolbar toolbar = findViewById(R.id.mytoolbar);
    12.         toolbar.setTitleTextAppearance(this, R.style.toolbarText);
    13.         setSupportActionBar(toolbar);
    14.         if(getSupportActionBar() != null){
    15.             getSupportActionBar().setElevation(4);
    16.             getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    17.         }
    18.  
    19.         progress = findViewById(R.id.progressBar);
    20.         progress.setVisibility(View.GONE);
    21.  
    22.         webview = findViewById(R.id.webView);
    23.         webview.getSettings().setJavaScriptEnabled(true);
    24.         webview.getSettings().setBuiltInZoomControls(true);
    25.         webview.getSettings().setDisplayZoomControls(false);
    26.         webview.getSettings().setLoadWithOverviewMode(true);
    27.         webview.getSettings().setUseWideViewPort(true);
    28.         webview.setWebViewClient(new MyWebViewClient());
    29.         webview.loadUrl(url);
    30.  
    31.         webview.setDownloadListener(new DownloadListener() {
    32.             public void onDownloadStart(String url,
    33.                                         String userAgent,
    34.                                         String contentDisposition,
    35.                                         String mimetype,
    36.                                         long contentLength) {
    37.                 String fileName = URLUtil.guessFileName(url, contentDisposition, mimetype);
    38.                 String cookie = CookieManager.getInstance().getCookie(url);
    39.  
    40.                 DownloadManager dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
    41.                 DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
    42.                 request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI | DownloadManager.Request.NETWORK_MOBILE);
    43.                 request.setAllowedOverRoaming(false);
    44.                 request.allowScanningByMediaScanner();
    45.                 request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, fileName);
    46.                 request.addRequestHeader("Cookie", cookie);
    47.                 request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
    48.                 if (dm != null) {
    49.                     dm.enqueue(request);
    50.                 }
    51.  
    52.             }
    53.         });
    54.  
    55.     }
    56.  
    57.     private class MyWebViewClient extends WebViewClient {
    58.         @Override
    59.         public boolean shouldOverrideUrlLoading(WebView view, String url) {
    60.             return super.shouldOverrideUrlLoading(view, url);
    61.         }
    62.  
    63.         @Override
    64.         public void onPageStarted(WebView view, String url, Bitmap favicon) {
    65.             progress.setVisibility(View.VISIBLE);
    66.             Stylo.this.progress.setProgress(0);
    67.             super.onPageStarted(view, url, favicon);
    68.         }
    69.  
    70.         @Override
    71.         public void onPageFinished(WebView view, String url) {
    72.             progress.setVisibility(View.GONE);
    73.             Stylo.this.progress.setProgress(100);
    74.             super.onPageFinished(view, url);
    75.         }
    76.  
    77.     }
    78.  
    79.     @Override
    80.     public void onBackPressed() {
    81.         if(webview.canGoBack()) {
    82.             webview.goBack();
    83.         } else {
    84.             super.onBackPressed();
    85.         }
    86.     }
     
  5. Deleted User

    Deleted User Guest

    What do you mean by "webview app"? Is this your app?
    Webview is a UI component provided by the Android SDK, as demonstrated above by @GameTheory . What do you think Webview means?
     
    GameTheory likes this.
  6. Deleted User

    Deleted User Guest

    I think you need to expand on this. Is it a server problem? Are you getting an exception in your app?
     
  7. dherst_4

    dherst_4 Lurker
    Thread Starter

    my first problem is not installing app
    AndroidManifest.xml
    Please fix this problem so I will send you an example of your main problem


    Code (Java):
    1. <?xml version="1.0" encoding="utf-8"?>
    2. <manifest
    3.     xmlns:android="http://schemas.android.com/apk/res/android"
    4.     xmlns:tools="http://schemas.android.com/tools"
    5.     android:installLocation="auto"
    6.     package="ir.picsgram.usershots">
    7.  
    8.     <uses-permission android:name="android.permission.INTERNET" />
    9.     <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    10.     <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    11.     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    12.     <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    13.     <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    14.     <uses-permission android:name="android.permission.CAMERA" />
    15.  
    16.     <application
    17.         android:name=".WebViewAppApplication"
    18.         android:icon="@mipmap/ic_launcher"
    19.         android:label="@string/app_name"
    20.         android:theme="@style/Theme.WebViewApp.Gray"
    21.         android:hardwareAccelerated="true"
    22.         android:allowBackup="true"
    23.         android:supportsRtl="true"
    24.         android:usesCleartextTraffic="true"
    25.         tools:ignore="AllowBackup,UnusedAttribute">
    26.  
    27.         <activity
    28.             android:name=".activity.MainActivity"
    29.             android:label="@string/app_name"
    30.             android:launchMode="standard"
    31.             android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
    32.             <intent-filter>
    33.                 <action android:name="android.intent.action.MAIN" />
    34.                 <category android:name="android.intent.category.LAUNCHER" />
    35.             </intent-filter>
    36.             <intent-filter>
    37.                 <action android:name="android.intent.action.VIEW" />
    38.                 <category android:name="android.intent.category.DEFAULT" />
    39.                 <category android:name="android.intent.category.BROWSABLE" />
    40.                 <data android:scheme="https" />
    41.                 <data android:host="@string/app_deep_link_host" />
    42.                 <data android:pathPrefix="@string/app_deep_link_path" />
    43.             </intent-filter>
    44.         </activity>
    45.  
    46.     </application>
    47. </manifest>
    48.  
     
  8. Deleted User

    Deleted User Guest

    When you say "not installing", what's the problem? Do you get an error? What happens when you try to install it directly from Android Studio?
    What error is in the Logcat?
     
  9. dherst_4

    dherst_4 Lurker
    Thread Starter

    Android Studio has no problem getting it out.

    i only have trouble installing the app on mobile
    And the installation time does not install

     
Loading...

Share This Page

Loading...