Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9007253
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:38:18+00:00 2026-06-16T01:38:18+00:00

So I have this Android Application that’s in WebView that should pass the data

  • 0

So I have this Android Application that’s in WebView that should pass the data to a server(hosting site), unfortunately I can’t do it so I need your help to solve this problem.

I got most of the code from this site so, it might looked familiar to you.

So I have this HTML file that initiate the function to send the data to a server.

watch_video.html

    var v_id = getUrlVars()["v_id"];

    $.ajax({

        url: "http://mysite.com/fbtest.php?json_callback=?",
        dataType: "jsonp text",       
        //GET method is used
        type: "POST",

        //pass the data         
        data: 'v_id=' + v_id,

        //Do not cache the page
        cache: false,

        //Cross Domain
        crossDomain: true,

        //success
        success: function (html) {    
            alert(html);         
        } 

So in PHP file which in a server(hosting site) that uses cross domain here’s the code:

<?php
include("includes/db.php");
header('content-type: application/json; charset=utf-8');
header('Access-Control-Allow-Origin: *');

$v_id = ($_POST['v_id']) ?$_POST['v_id'] : $_GET['v_id'];
$dwatch=date("Y-m-d");
$twatch=date("H:i:s");

$query="insert into watched_videos (fb_id,vid,date_watched,time_watched) values('12345','".$v_id."','".$dwatch."','".$twatch."')";
        $row = mysql_query($query);
?>

I tested this locally using XAMPP, it works it inserted the data in a database.

When I installed it in Android, and did the same function it didn’t worked.

Here’s my MainActivity.java code:

package namename.name;

import android.os.Bundle;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.view.KeyEvent;
import android.view.Menu;
import android.webkit.WebSettings.PluginState;
import android.webkit.WebView;


public class MainActivity extends Activity {

    @SuppressLint("SetJavaScriptEnabled")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        WebView mWebView = null;
        mWebView = (WebView) findViewById(R.id.webtest);
        mWebView.getSettings().setPluginState(PluginState.ON);
        mWebView.getSettings().setJavaScriptEnabled(true);
        mWebView.loadUrl("file:///android_asset/www/indexbackup.html");
    }


    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        WebView mWebView = null;
        mWebView = (WebView) findViewById(R.id.webtest);
        if(event.getAction() == KeyEvent.ACTION_DOWN){
            switch(keyCode)
            {
            case KeyEvent.KEYCODE_BACK:
                if(mWebView.canGoBack() == true){
                    mWebView.goBack();
                }else{
                    finish();
                }
                return true;
            }

        }
        return super.onKeyDown(keyCode, event);
    }

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

}

So going back to what I’ve said before I initiated the function in WebView using JSONP it did not work.

I was wondering if I have something to put in my android file or so.

I would be glad if someone helps me.

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T01:38:20+00:00Added an answer on June 16, 2026 at 1:38 am

    the problem is with this line

    mWebView.loadUrl("file:///android_asset/www/indexbackup.html");
    

    you have to give proper file path like a browser

    mWebView.loadUrl("http://yoursite/android_asset/www/indexbackup.html");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have this android application that requires to load data from a remote server
I have an Android application that communicates with a server on a hosting provider.
I have a Web Service and an Android application that uses this web service.
this is for an Android application, I have an XML file that I would
I have an Android application, backed by an API. To this API users can
I have an Android application that is a TabHost with a WebView. I use
I have an Android application that simply saves data and displays them in a
I am developing an android application that receives SMS messages and uses this data
I have an Android application that goes about like this: <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android xmlns:tools=http://schemas.android.com/tools android:layout_width=match_parent
I have an Android application that writes data to the SD card. I want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.