So injizieren Sie Bilder von der nativen App in WebView und laden Sie auf den Server hochJava

Java-Forum
Anonymous
 So injizieren Sie Bilder von der nativen App in WebView und laden Sie auf den Server hoch

Post by Anonymous »

Ich habe den folgenden Code, den ich in meiner Anwendung in WebView auf Server auf den Server hochladen möchte, aber nicht funktioniert. So injizieren Sie Bilder von der nativen App in WebView und laden Sie auf Server hoch.

Code: Select all

   @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode==123 && resultCode==RESULT_OK) {

// Checking whether data is null or not
if (data != null) {

// Checking for selection multiple files or single.
if (data.getClipData() != null) {

// Getting the length of data and logging up the logs using index
for (int index = 0; index < data.getClipData().getItemCount(); index++) {

// Getting the URIs of the selected files and logging them into logcat at debug level
Uri uri = data.getClipData().getItemAt(index).getUri();
Log.d("filesUri [" + uri + "] : ", String.valueOf(uri));

MainActivity.this.myWebView.loadUrl("javascript:window.INTERFACE.ximagex(document.getElementById('image').src='"+uri+"');");
}
} else {

// Getting the URI of the selected file and logging into logcat at debug level
Uri uri = data.getData();
Log.d("fileUri: ", String.valueOf(uri));
}
}

}
< /code>
} < /p>
    public void timer() {
this.countDownTimer = new CountDownTimer(5000000, 5000) {
public void onTick(long millisUntilFinished) {
MainActivity.this.myWebView.loadUrl("javascript:window.INTERFACE.ximage(document.getElementById('ximage').value);");
// Intent i = new Intent(MainActivity.this, ImageActivity.class);
//startActivity(i);
if (Integer.valueOf(ximage) == 1) {
//onFinish();
Intent intent = new Intent()
.setType("image/*")
.setAction(Intent.ACTION_GET_CONTENT);
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
startActivityForResult(Intent.createChooser(intent, "Select a file"), 123);
MainActivity.this.myWebView.loadUrl("javascript:window.INTERFACE.ximage(document.getElementById('ximage').value ='0');");

}
}

public void onFinish() {
countDownTimer.cancel();
}
}.start();
}

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post