Skip to main content

Enable Downloads In Your Web Browser

Enable Downloads In Your WebBrowser





Latest Tutorial..!


1) Create a new Web Browser  project in Sketchware
     Below are some tutorials regarding this topic.
     Please watch these tutorials . These tutorials will help you in understanding the topic.

Part 1




Part 2






Part 3










3) Export the project which you have created in Sketchware to AIDE or Android Studio



4) Navigate to AndroidManifest.xml and add the following permission

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />




5) Now Open MainActivity.java or the Java File where you want to add the Download Listener
     and add the following code


        webview1.setDownloadListener(new DownloadListener() {       

               @Override
                    public void onDownloadStart(String url, String userAgent,
                     String contentDisposition, String mimetype,
                      long contentLength) {
                       DownloadManager.Request request = new DownloadManager.Request(
                          Uri.parse(url));

            request.allowScanningByMediaScanner();
                                           request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMP                    LETED); 
            request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS,                      "Your   Downloads ");
            DownloadManager dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
            dm.enqueue(request);
            Toast.makeText(getApplicationContext(), "Downloading File", 
                    Toast.LENGTH_LONG).show();

        }
    });


Here is a Video  Tutorial 











Thats all.... Now compile and Run The App . Now Your Webview should be able to Download Files.






If you Face Any Problem , Comment Below...




Comments

Did you like this tutorial ?

Popular posts from this blog

Add Edittext Inside Dialog Box

Add Edittext Inside Dialog Box




If you haven`t yet watched the video...Watch it right now!!!


The code used in the above video is available here.
final EditText edittext1= new EditText(MainActivity.this); LinearLayout.LayoutParams lpar = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); edittext1.setLayoutParams(lpar); dialog.setView(edittext1);







textview1.setText(edittext1.getText());






Create Custom Popup Window using Sketchware

Create Custom Popup Window using Sketchware


Refer the video below if  you get stuck. 

1) Add a custom view named window.You can name it according to your wish. 
2)Design your popup window. 
2) Now, In the logic section,In OnCLick event of button.Add the following  code
Create a view
View popupView = getLayoutInflater().inflate(R.layout.window, null);
Popup window 

final PopupWindow popup = new PopupWindow(popupView, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, true);
Initialize 
Button b1 = popupView.findViewById(R.id.button1); Button b2 = popupView.findViewById(R.id.button2);
OnClickListeners
b1.setOnClickListener(new OnClickListener() { public void onClick(View view) { //below code will dismiss the popup window popup.dismiss(); } });
b2.setOnClickListener(new OnClickListener() { public void onClick(View view) {
popup.dismiss(); } });
Show the popup window 
popup.showAtLocation(popupView, Gravity.CENTER, 0, 0);




Add Swipe To Refresh Feature To Your App using Android Studio

Add Swipe To Refresh Feature To Your App Using Android Studio


If you haven't watched the video watch it now!


Source Code
Android Manifest.xml



<manifest xmlns:android="http://schemas.android.com/apk/res/android"package="swiperefresh.com.swipetorefresh"> <uses-permission android:name="android.permission.INTERNET" /> <applicationandroid:allowBackup="true"android:icon="@mipmap/ic_launcher"android:label="@string/app_name"android:roundIcon="@mipmap/ic_launcher_round"android:supportsRtl="true"android:theme="@style/AppTheme"> <activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>…