File upload 如何使用webview实现推送通知和文件上传下载?

File upload 如何使用webview实现推送通知和文件上传下载?,file-upload,webview,push-notification,download,File Upload,Webview,Push Notification,Download,我想知道我的应用程序如何提醒用户他们在我的论坛上有通知?此外,我还想知道如何允许用户在应用程序中向我的论坛上传和下载文件。我正在使用webview,不确定我的代码是否是最新的。说到这件事,我是个笨蛋 这是我的密码: package technologx.technologx; /** * Created by Technologx on 12/22/15 * ©2015 Technologx All Rights Reserved * http://technologx.fulba.co

我想知道我的应用程序如何提醒用户他们在我的论坛上有通知?此外,我还想知道如何允许用户在应用程序中向我的论坛上传和下载文件。我正在使用webview,不确定我的代码是否是最新的。说到这件事,我是个笨蛋

这是我的密码:

package technologx.technologx;

/**
 * Created by Technologx on 12/22/15
 * ©2015 Technologx All Rights Reserved
 * http://technologx.fulba.com
 */

import android.os.Build;
import android.os.Bundle;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.webkit.CookieSyncManager;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.google.android.gms.appindexing.Action;
import com.google.android.gms.appindexing.AppIndex;
import com.google.android.gms.common.api.GoogleApiClient;

@SuppressLint("SetJavaScriptEnabled")
public class MainActivity extends Activity {


    /**
     * ATTENTION: This was auto-generated to implement the App Indexing API.
     * See https://g.co/AppIndexing/AndroidStudio for more information.
     */
    private GoogleApiClient client;

    private WebView webView;

    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        // If the Android version is lower than Jellybean, use this call to hide
        // the status bar.
        if (Build.VERSION.SDK_INT < 16) {
            getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                    WindowManager.LayoutParams.FLAG_FULLSCREEN);
        }

        // Adds Progress Bar Support
        this.getWindow().requestFeature(Window.FEATURE_PROGRESS);
        // Makes Progress Bar Visible
        getWindow().setFeatureInt(Window.FEATURE_PROGRESS, Window.PROGRESS_VISIBILITY_ON);

        // Use forum.xml as webview layout
        setContentView(R.layout.activity_main);

        webView = (WebView) findViewById(R.id.webView);
        webView.getSettings().setJavaScriptEnabled(true);

        // Adds Zoom Control (You may not need this)
        webView.getSettings().setSupportZoom(true);

        // Enables Multi-Touch. if supported by ROM
        webView.getSettings().setBuiltInZoomControls(true);

        // Change to your own forum url
        webView.loadUrl("http://technologx.96.lt/");

        webView.setWebViewClient(new WebViewClient() {
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                // Loads only your forum domain and no others!
                if (url.contains("technologx.96.lt") == true) {
                    view.loadUrl(url);
                    // Adds Progress Bar Support
                    super.onPageStarted(view, url, null);
                    findViewById(R.id.progressbar).setVisibility(View.VISIBLE);
                    // If they are not your domain, use browser instead
                } else {
                    Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
                    startActivity(i);
                }
                return true;
            }

            @Override
            public void onPageFinished(WebView view, String url) {
                // Removes Progress Bar
                findViewById(R.id.progressbar).setVisibility(View.GONE);
                // Adds Cookies. Yummy!
                CookieSyncManager.getInstance().sync();
            }
        });
        // ATTENTION: This was auto-generated to implement the App Indexing API.
        // See https://g.co/AppIndexing/AndroidStudio for more information.
        client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build();
    }

    @Override
    public void onBackPressed() {
        // Enables going back history
        if (webView.copyBackForwardList().getCurrentIndex() > 0) {
            webView.goBack();
        } else {
            // Your exit alert code, or alternatively line below to finish
            // Finishes forum activity
            super.onBackPressed();
        }
    }

    @Override
    public void onStart() {
        super.onStart();

        // ATTENTION: This was auto-generated to implement the App Indexing API.
        // See https://g.co/AppIndexing/AndroidStudio for more information.
        client.connect();
        Action viewAction = Action.newAction(
                Action.TYPE_VIEW, // TODO: choose an action type.
                "Main Page", // TODO: Define a title for the content shown.
                // TODO: If you have web page content that matches this app activity's content,
                // make sure this auto-generated web page URL is correct.
                // Otherwise, set the URL to null.
                Uri.parse("http://host/path"),
                // TODO: Make sure this auto-generated app deep link URI is correct.
                Uri.parse("android-app://technologx.technologx/http/host/path")
        );
        AppIndex.AppIndexApi.start(client, viewAction);
    }

    @Override
    public void onStop() {
        super.onStop();

        // ATTENTION: This was auto-generated to implement the App Indexing API.
        // See https://g.co/AppIndexing/AndroidStudio for more information.
        Action viewAction = Action.newAction(
                Action.TYPE_VIEW, // TODO: choose an action type.
                "Main Page", // TODO: Define a title for the content shown.
                // TODO: If you have web page content that matches this app activity's content,
                // make sure this auto-generated web page URL is correct.
                // Otherwise, set the URL to null.
                Uri.parse("http://host/path"),
                // TODO: Make sure this auto-generated app deep link URI is correct.
                Uri.parse("android-app://technologx.technologx/http/host/path")
        );
        AppIndex.AppIndexApi.end(client, viewAction);
        client.disconnect();
    }
}
package technologx.technologx;
/**
*由Technologx于2015年12月22日创建
*©2015 Technologyx版权所有
* http://technologx.fulba.com
*/
导入android.os.Build;
导入android.os.Bundle;
导入android.annotation.SuppressLint;
导入android.app.Activity;
导入android.content.Intent;
导入android.net.Uri;
导入android.view.view;
导入android.view.Window;
导入android.view.WindowManager;
导入android.webkit.CookieSyncManager;
导入android.webkit.WebView;
导入android.webkit.WebViewClient;
导入com.google.android.gms.appindexing.Action;
导入com.google.android.gms.AppIndex.AppIndex;
导入com.google.android.gms.common.api.GoogleAppClient;
@SuppressLint(“SetJavaScriptEnabled”)
公共类MainActivity扩展了活动{
/**
*注意:这是自动生成的,用于实现应用程序索引API。
*看https://g.co/AppIndexing/AndroidStudio 了解更多信息。
*/
私人谷歌客户;
私有网络视图;
创建时的公共void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
//如果Android版本低于Jellybean,请使用此调用隐藏
//状态栏。
如果(Build.VERSION.SDK_INT<16){
getWindow().setFlags(WindowManager.LayoutParams.FLAG_全屏,
WindowManager.LayoutParams.FLAG(全屏);
}
//添加进度条支持
this.getWindow().requestFeature(Window.FEATURE\u进度);
//使进度条可见
getWindow().setFeatureInt(Window.FEATURE\u进度,Window.PROGRESS\u可见性\u打开);
//使用forum.xml作为webview布局
setContentView(R.layout.activity_main);
webView=(webView)findviewbyd(R.id.webView);
webView.getSettings().setJavaScriptEnabled(true);
//添加缩放控件(您可能不需要此控件)
webView.getSettings().setSupportZoom(true);
//启用多点触摸。如果ROM支持
webView.getSettings().setBuilTinZoomControl(true);
//更改为您自己的论坛url
webView.loadUrl(“http://technologx.96.lt/");
setWebViewClient(新的WebViewClient(){
公共布尔值shouldOverrideUrlLoading(WebView视图,字符串url){
//仅加载您的论坛域,不加载其他域!
if(url.contains(“technologx.96.lt”)==true){
view.loadUrl(url);
//添加进度条支持
super.onPageStarted(视图、url、空);
findviewbyd(R.id.progressbar).setVisibility(View.VISIBLE);
//如果它们不是您的域,请改用浏览器
}否则{
Intent i=新的Intent(Intent.ACTION_视图,Uri.parse(url));
星触觉(i);
}
返回true;
}
@凌驾
公共void onPageFinished(WebView视图,字符串url){
//删除进度条
findviewbyd(R.id.progressbar).setVisibility(View.GONE);
//添加饼干。好吃!
CookieSyncManager.getInstance().sync();
}
});
//注意:这是自动生成的,用于实现应用程序索引API。
//看https://g.co/AppIndexing/AndroidStudio 了解更多信息。
client=new GoogleApiClient.Builder(this.addApi(AppIndex.API).build();
}
@凌驾
public void onBackPressed(){
//允许追溯历史
如果(webView.copyBackForwardList().getCurrentIndex()>0){
webView.goBack();
}否则{
//您的退出警报代码,或者在下面的行中完成
//完成论坛活动
super.onBackPressed();
}
}
@凌驾
public void onStart(){
super.onStart();
//注意:这是自动生成的,用于实现应用程序索引API。
//看https://g.co/AppIndexing/AndroidStudio 了解更多信息。
client.connect();
Action viewAction=Action.newAction(
Action.TYPE\u视图,//TODO:选择一种操作类型。
“主页面”//TODO:为显示的内容定义标题。
//TODO:如果您的网页内容与此应用程序活动的内容匹配,
//确保此自动生成的网页URL正确无误。
//否则,请将URL设置为null。
解析http://host/path"),
//TODO:确保此自动生成的应用程序深度链接URI正确。
解析-app://technologx.technologx/http/host/path")
);
AppIndex.AppIndexApi.start(客户端,viewAction);
}
@凌驾
公共void onStop(){
super.onStop();
//注意:这是自动生成的,用于实现应用程序索引API。
//看https://g.co/AppIndexing/AndroidStudio 了解更多信息。
Action viewAction=Action.newAction(
Action.TYPE\u视图,//TODO:选择一种操作类型。
“主页面”//TODO:为显示的内容定义标题。
//TODO:如果您的网页内容与此应用程序活动的内容匹配,
//确保此自动生成的网页URL正确无误。
//否则,请将URL设置为null。
解析http://host/path"),
//TODO:确保此自动生成的应用程序深度链接URI正确。
解析-app://te