在Android中选择附件与相机选项

时间:2015-08-01 13:16:25

标签: android upload camera attachment

我是android的超级新手。只是看看网上的示例代码并尝试设计我的。

我正在尝试设计一个打开网站的Webview应用程序。到目前为止它的工作,至少在我的手机上(4.4)

这是我的代码

package com.Mywebsite.Mywebsite;

import android.app.Activity;
import android.os.Handler;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.Toast;


public class MainActivity extends Activity {

    private WebView mWebView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        //Web App Code

        mWebView = (WebView) findViewById(R.id.activity_main_webview);

        // Set user-agent

        mWebView.getSettings().setUserAgentString("Mywebsite.android");

        // Enable Javascript

        WebSettings webSettings = mWebView.getSettings();
        webSettings.setJavaScriptEnabled(true);

        View view=findViewById(R.id.imageLoading1);
        view.postDelayed(new Runnable() {
            public void run() {
                findViewById(R.id.imageLoading1).setVisibility(View.GONE);
                findViewById(R.id.activity_main_webview).setVisibility(View.VISIBLE);

            }
        }, 5000);

        //Load Site URL

        mWebView.loadUrl("http://Mywebsite.com/");

        // Force links and redirects to open in the WebView instead of in a browser
        mWebView.setWebViewClient(new MyAppWebViewClient()

                                          // Error Page
                                  {
                                      public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
                                          mWebView.loadUrl("file:///android_asset/www/nonetwork.html");
                                      }
                                  }
        );


    }

    private boolean doubleBackToExitPressedOnce;
    @Override
    public void onBackPressed() {
        if (doubleBackToExitPressedOnce) {
            super.onBackPressed();
            return;
        }

        this.doubleBackToExitPressedOnce = true;
        Toast.makeText(this, "Press Again To Close", Toast.LENGTH_SHORT).show();

        new Handler().postDelayed(new Runnable() {

            @Override
            public void run() {
                doubleBackToExitPressedOnce=false;
            }
        }, 2000);
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
}

问题是我的网站有附件选项无效。我将非常感谢您的帮助。提前谢谢。

REGD 的Shahriar

0 个答案:

没有答案