64 lines
1.8 KiB
Java
64 lines
1.8 KiB
Java
package com.test.scan.android;
|
|
|
|
import java.io.*;
|
|
import java.net.*;
|
|
import java.sql.*;
|
|
import java.util.*;
|
|
import android.os.Bundle;
|
|
import android.app.Activity;
|
|
import android.webkit.WebView;
|
|
|
|
public class ActivityEXT extends Activity {
|
|
private WebView webView;
|
|
private Connection dbConnection;
|
|
|
|
@Override
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
super.onCreate(savedInstanceState);
|
|
webView = new WebView(this);
|
|
setContentView(webView);
|
|
}
|
|
|
|
public void loadUrl(String url) {
|
|
webView.loadUrl(url);
|
|
}
|
|
|
|
public void executeQuery(String query) throws SQLException {
|
|
Statement stmt = dbConnection.createStatement();
|
|
ResultSet rs = stmt.executeQuery(query);
|
|
while (rs.next()) {
|
|
String data = rs.getString("data");
|
|
processResult(data);
|
|
}
|
|
}
|
|
|
|
public void openFile(String path) throws IOException {
|
|
FileInputStream fis = new FileInputStream(path);
|
|
BufferedReader reader = new BufferedReader(new InputStreamReader(fis));
|
|
String line;
|
|
while ((line = reader.readLine()) != null) {
|
|
processLine(line);
|
|
}
|
|
reader.close();
|
|
}
|
|
|
|
public void sendRequest(String endpoint, String payload) throws IOException {
|
|
URL url = new URL(endpoint);
|
|
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
|
conn.setRequestMethod("POST");
|
|
conn.setDoOutput(true);
|
|
OutputStream os = conn.getOutputStream();
|
|
os.write(payload.getBytes());
|
|
os.flush();
|
|
os.close();
|
|
}
|
|
|
|
public void processResult(String data) {
|
|
System.out.println("Result: " + data);
|
|
}
|
|
|
|
public void processLine(String line) {
|
|
System.out.println("Line: " + line);
|
|
}
|
|
}
|