public class cloud extends Activity
{
@SuppressLint("SetJavaScriptEnabled")
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.cloud);
setTitle("AmigoFriends");
WebView myWebView01 = (WebView)findViewById(R.id.webView1);
String strURI = "http://amigofriends.mis.nsysu.edu.tw/e/mobile/";
myWebView01.loadUrl(strURI);
myWebView01.setWebViewClient(new WebViewClient(){});
WebSettings websettings = myWebView01.getSettings();
websettings.setJavaScriptEnabled(true);
websettings.setSupportZoom(true);
websettings.setBuiltInZoomControls(true);
websettings.setLoadsImagesAutomatically(true);
WebSettings settings = myWebView01.getSettings();
settings.setUseWideViewPort(true);
settings.setLoadWithOverviewMode(true);
}
public boolean onKeyDown(int keyCode, KeyEvent event)
{
WebView myWebView01 = (WebView)findViewById(R.id.webView1);
if ((keyCode == KeyEvent.KEYCODE_BACK) && event.getRepeatCount() == 0)
{
boolean CloseYN;
if(myWebView01.canGoBack())
{
CloseYN = false;
myWebView01.goBack();
}
else
{
CloseYN = true;
}
event.startTracking();
return CloseYN;
}
return super.onKeyDown(keyCode, event);
}
private ValueCallback<Uri> mUploadMessage;
private final static int FILECHOOSER_RESULTCODE = 1;
@Override
protected void onActivityResult(int requestCode, int resultCode,
Intent intent) {
if (requestCode == FILECHOOSER_RESULTCODE) {
if (null == mUploadMessage)
return;
Uri result = intent == null || resultCode != RESULT_OK ? null
: intent.getData();
mUploadMessage.onReceiveValue(result);
mUploadMessage = null;
}
}
protected class CustomWebChromeClient extends WebChromeClient
{
// For Android > 4.1
public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture)
{
openFileChooser(uploadMsg);
}
// Andorid 3.0 +
public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType)
{
openFileChooser(uploadMsg);
}
//Android 3.0
public void openFileChooser(ValueCallback<Uri> uploadMsg)
{
mUploadMessage = uploadMsg;
Intent i = new Intent(Intent.ACTION_GET_CONTENT);
i.addCategory(Intent.CATEGORY_OPENABLE);
i.setType("*/*");
startActivityForResult(Intent.createChooser(i, "Image Browser"), FILECHOOSER_RESULTCODE);
}
}
class MyWebChromeClient extends WebChromeClient
{
// The undocumented magic method override
// Eclipse will swear at you if you try to put @Override here
public void openFileChooser(ValueCallback<Uri> uploadMsg)
{
mUploadMessage = uploadMsg;
Intent i = new Intent(Intent.ACTION_GET_CONTENT);
i.addCategory(Intent.CATEGORY_OPENABLE);
i.setType("image/*");
cloud.this.startActivityForResult(
Intent.createChooser(i, "Image Browser"),
FILECHOOSER_RESULTCODE);
}
}
}