如何从android发送数据到mysql服务器?

2024-03-29

我是android开发的新手。我正在使用 Android Studio。我正在制作一个应用程序,其中有一个名称下拉列表。选择任何名称后,相应的ID该名称显示在应用程序中。然后有一个按钮将搜索用户当前的 GPS 坐标并将其显示在应用程序上。我搜索了类似的问题并找到了一些链接(我将在最后发布)但我无法理解它们。以下是该应用程序的屏幕截图

我在mysql中有两个表;users and activity, 如下所示

Users

Activity

The UserId是活动表中的外键,即Id from users表将被插入其中。

我创建了以下脚本以将数据返回为 JSON:

<?php
    require_once ('config.php');

    $sql = "SELECT * FROM users";  
    $r = mysqli_query($con,$sql); 
    $result = array();

    while($row = mysqli_fetch_array($r)){
        array_push($result,array(
            'Id'=>$row['Id'],
            'Name'=>$row['Name']
        )); 
      }//end while

    echo json_encode(array('users'=>$result));

    mysqli_close($con);
?>

在我的应用程序代码中我创建了一个users class

用户等级

public class Users {

private String Id;
private String Name;

public String getId() {
    return Id;
}

public void setId(String id) {
    this.Id = id;
}

public String getName() {
    return Name;
}

public void setName(String name) {
    this.Name = name;
}}

JSON类

public class JSONfunctions {


public static JSONObject getJSONfromURL(String url)
{

    String json = "";
    JSONObject jsonObject = null;
    try
    {
        HttpClient httpClientt = new DefaultHttpClient();
        HttpGet httpGet = new HttpGet(url);
        HttpResponse httpResponse = httpClientt.execute(httpGet);
        BufferedReader br = new BufferedReader(new InputStreamReader(httpResponse.getEntity().getContent()));
        StringBuffer sb = new StringBuffer();
        String line = "";
        while ((line = br.readLine()) != null) {
            sb.append(line);
        }

        json = sb.toString();
    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    try
    {
        jsonObject = new JSONObject(json);
    } catch (JSONException e) {
        e.printStackTrace();
    }

    return jsonObject;
}

主要活动

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

    _latitude = (TextView)findViewById(R.id.latitude);
    _longitude = (TextView)findViewById(R.id.longitude);
    btn_get_coordinates = (Button)findViewById(R.id.button);




    final PermissionListener permissionlistener = new PermissionListener() {
        @Override
        public void onPermissionGranted() {
            //Toast.makeText(MainActivity.this, "Permission Granted", Toast.LENGTH_SHORT).show();

            buildGoogleApiClient();
            //checkLocation(); //check whether location service is enable or not in your  phone
        }

        @Override
        public void onPermissionDenied(ArrayList<String> deniedPermissions) {
            Toast.makeText(MainActivity.this, "Permission Denied\n" + deniedPermissions.toString(), Toast.LENGTH_SHORT).show();
        }
    };

    btn_get_coordinates.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {


            new TedPermission(MainActivity.this)
                    .setPermissionListener(permissionlistener)
                    .setRationaleMessage("This app needs Permission to find your location")
                    .setPermissions(Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION)
                    .check();


        }
    });

    // Download JSON file AsyncTask
    new DownloadJSON().execute();
}

/////////////////////////////////////// Start of Location Services ///////////////////////////////////////////////////////

protected synchronized  void buildGoogleApiClient() {

    mGoogleApiClient = new GoogleApiClient.Builder(this)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .addApi(LocationServices.API)
            .build();

    if (mGoogleApiClient != null) {
        mGoogleApiClient.connect();
    } else
        Toast.makeText(this, "Not Connected!", Toast.LENGTH_SHORT).show();

}


/*Ending the updates for the location service*/
@Override
protected void onStop() {
    mGoogleApiClient.disconnect();
    super.onStop();
}

@Override
public void onConnected(@Nullable Bundle bundle) {
    settingRequest();
}

@Override
public void onConnectionSuspended(int i) {
    Toast.makeText(this, "Connection Suspended!", Toast.LENGTH_SHORT).show();
}

@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
    Toast.makeText(this, "Connection Failed!", Toast.LENGTH_SHORT).show();
    if (connectionResult.hasResolution()) {
        try {
            // Start an Activity that tries to resolve the error
            connectionResult.startResolutionForResult(this, 90000);
        } catch (IntentSender.SendIntentException e) {
            e.printStackTrace();
        }
    } else {
        Log.i("Current Location", "Location services connection failed with code " + connectionResult.getErrorCode());
    }
}


/*Method to get the enable location settings dialog*/
public void settingRequest() {
    mLocationRequest = new LocationRequest();
    mLocationRequest.setInterval(10000);    // 10 seconds, in milliseconds
    mLocationRequest.setFastestInterval(1000);   // 1 second, in milliseconds
    mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);

    LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder()
            .addLocationRequest(mLocationRequest);

    PendingResult<LocationSettingsResult> result =
            LocationServices.SettingsApi.checkLocationSettings(mGoogleApiClient,
                    builder.build());

    result.setResultCallback(new ResultCallback<LocationSettingsResult>() {

        @Override
        public void onResult(@NonNull LocationSettingsResult result) {
            final Status status = result.getStatus();
            final LocationSettingsStates state = result.getLocationSettingsStates();
            switch (status.getStatusCode()) {
                case LocationSettingsStatusCodes.SUCCESS:
                    // All location settings are satisfied. The client can
                    // initialize location requests here.
                    getLocation();
                    break;
                case LocationSettingsStatusCodes.RESOLUTION_REQUIRED:
                    // Location settings are not satisfied, but this can be fixed
                    // by showing the user a dialog.
                    try {
                        // Show the dialog by calling startResolutionForResult(),
                        // and check the result in onActivityResult().
                        status.startResolutionForResult(MainActivity.this, 1000);
                    } catch (IntentSender.SendIntentException e) {
                        // Ignore the error.
                    }
                    break;
                case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE:
                    // Location settings are not satisfied. However, we have no way
                    // to fix the settings so we won't show the dialog.
                    break;
            }
        }

    });
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    final LocationSettingsStates states = LocationSettingsStates.fromIntent(data);
    switch (requestCode) {
        case 1000:
            switch (resultCode) {
                case Activity.RESULT_OK:
                    // All required changes were successfully made
                    getLocation();
                    break;
                case Activity.RESULT_CANCELED:
                    // The user was asked to change settings, but chose not to
                    Toast.makeText(this, "Location Service not Enabled", Toast.LENGTH_SHORT).show();
                    break;
                default:
                    break;
            }
            break;
    }
}


public void getLocation() {
    if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
        // TODO: Consider calling
        //    ActivityCompat#requestPermissions
        // here to request the missing permissions, and then overriding
        //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
        //                                          int[] grantResults)
        // to handle the case where the user grants the permission. See the documentation
        // for ActivityCompat#requestPermissions for more details.
        return;
    } else {
        /*Getting the location after aquiring location service*/
        mLastLocation = LocationServices.FusedLocationApi.getLastLocation(
                mGoogleApiClient);

        if (mLastLocation != null) {
           // _progressBar.setVisibility(View.INVISIBLE);
            _latitude.setText("Latitude: " + String.valueOf(mLastLocation.getLatitude()));
            _longitude.setText("Longitude: " + String.valueOf(mLastLocation.getLongitude()));
        } else {
            /*if there is no last known location. Which means the device has no data for the loction currently.
            * So we will get the current location.
            * For this we'll implement Location Listener and override onLocationChanged*/
            Log.i("Current Location", "No data for location found");

            if (!mGoogleApiClient.isConnected())
                mGoogleApiClient.connect();

            LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, MainActivity.this);
        }
    }
}



@Override
public void onLocationChanged(Location location) {

    mLastLocation = location;
    _progressBar.setVisibility(View.INVISIBLE);
    _latitude.setText("Latitude: " + String.valueOf(mLastLocation.getLatitude()));
    _longitude.setText("Longitude: " + String.valueOf(mLastLocation.getLongitude()));

}

//////////////////////////////////////////// End of Location services ///////////////////////////////////////////////


////////////////////////////////////////// Start of getting JSON DATA ///////////////////////////////////////////////

// Download JSON file AsyncTask
private class DownloadJSON extends AsyncTask<Void, Void, Void>
{

   /* @Override
    protected void onPreExecute() {
        super.onPreExecute();
        progressDialog = new ProgressDialog(MainActivity.this);
        progressDialog.setMessage("Fetching Users....!");
        progressDialog.setCancelable(false);
        progressDialog.show();

    }*/

    @Override
    protected Void doInBackground(Void... params) {

        // Locate the Users Class
        users = new ArrayList<Users>();

        // Create an array to populate the spinner
        userList = new ArrayList<String>();
        // http://10.0.2.2:8000/MobileApp/index.php
        //http://10.0.2.2:8000/app/web/users/
        //http://192.168.100.8:8000/app/web/users/
        // JSON file URL address
        jsonObject = JSONfunctions.getJSONfromURL("http://192.168.100.15:8000/MobileApp/GET_DATA.php");

        try
        {
            JSONObject jobj = new JSONObject(jsonObject.toString());
            // Locate the NodeList name
            jsonArray = jobj.getJSONArray("users");

            for(int i=0; i<jsonArray.length(); i++)
            {
                jsonObject = jsonArray.getJSONObject(i);

                Users user = new Users();

                user.setId(jsonObject.optString("Id"));
                user.setName(jsonObject.optString("Name"));
                users.add(user);

                userList.add(jsonObject.optString("Name"));

            }
        } catch (JSONException e) {
            Log.e("Error", e.getMessage());
            e.printStackTrace();
        }


        return null;
    }

    @Override
    protected void onPostExecute(Void args)
    {
        // Locate the spinner in activity_main.xml
        Spinner spinner = (Spinner)findViewById(R.id.spinner);

        // Spinner adapter
        spinner.setAdapter(new ArrayAdapter<String>(MainActivity.this, android.R.layout.simple_spinner_dropdown_item, userList));

        // Spinner on item click listener

        spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {

                textViewResult = (TextView)findViewById(R.id.textView);

                // Set the text followed by the position

                textViewResult.setText("Hi " + users.get(position).getName() + " your ID is " + users.get(position).getId());

            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {
                textViewResult.setText("");
            }
        });
    }


}
//////////////////////////////////////// End of getting JSON DATA //////////////////////////////////////////

当我按下保存按钮时,以下字段将被插入到Activity table

  1. Id(这是自增)
  2. UserId(用户表中基于所选名称的用户 ID)
  3. Latitude(当前用户)
  4. Longitude(当前用户)
  5. DateTime(用户的日期时间)

我是否应该像我创建的那样创建一个“活动”类User class?

为此我有一些想法

  1. 我会将数据保存到xml or txt首先创建文件,然后将其保存到数据库中。
  2. 我应该将数据转换为json格式化然后保存到DB
  3. 使用 my 中的查询直接将其保存到数据库中php script

这 3 个中哪一个最容易实现?如果有人能为我提供教程,那将非常有帮助,尽管我看到了其中很多(1 https://stackoverflow.com/a/32200552/6854117 , )并且如上所述我无法理解它们:(。

我被困住了,不知道自己必须做什么。任何帮助将不胜感激。


您需要编写 Api,您可以在其中传递来自 android 的数据,并在 Api 中获取该数据并使用插入查询存储在数据库中。在 Android 端,你必须执行以下代码:

我的类 PutUtility 用于 getData()、PostData、DeleteData()。你只需要更改包名称

package fourever.amaze.mics;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Map;


public class PutUtility {

    private Map<String, String> params = new HashMap<>();
    private static HttpURLConnection httpConnection;
    private static BufferedReader reader;
    private static String Content;
    private StringBuffer sb1;
    private StringBuffer response;

    public void setParams(Map<String, String> params) {
        this.params = params;
    }

    public void setParam(String key, String value) {
        params.put(key, value);
    }

    public String getData(String Url) {


        StringBuilder sb = new StringBuilder();

        try {
            // Defined URL  where to send data

            URL url = new URL(Url);

            URLConnection conn = null;
            conn = url.openConnection();

            // Send POST data request
            httpConnection = (HttpURLConnection) conn;
            httpConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
            httpConnection.setRequestMethod("GET");

            BufferedReader in = new BufferedReader(
                    new InputStreamReader(httpConnection.getInputStream()));
            String inputLine;
            response = new StringBuffer();



            while ((inputLine = in.readLine()) != null) {
                response.append(inputLine);
            }
            in.close();

        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                reader.close();
            } catch (Exception ex) { }
        }

        return response.toString();
    }


    public String postData(String Url) {


        StringBuilder sb = new StringBuilder();
        for (String key : params.keySet()) {
            String value = null;
            value = params.get(key);


            if (sb.length() > 0) {
                sb.append("&");
            }
            sb.append(key + "=" + value);
        }

        try {
            // Defined URL  where to send data

            URL url = new URL(Url);

            URLConnection conn = null;
            conn = url.openConnection();

            // Send POST data request
            httpConnection = (HttpURLConnection) conn;
            httpConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
            httpConnection.setRequestMethod("POST");
            httpConnection.setDoInput(true);
            httpConnection.setDoOutput(true);
            OutputStreamWriter wr = null;

            wr = new OutputStreamWriter(conn.getOutputStream());
            wr.write(sb.toString());
            wr.flush();

            BufferedReader in = new BufferedReader(
                    new InputStreamReader(httpConnection.getInputStream()));
            String inputLine;
            response = new StringBuffer();

            while ((inputLine = in.readLine()) != null) {
                response.append(inputLine);
            }
            in.close();

        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {

                reader.close();
            } catch (Exception ex) {
            }
        }


        return response.toString();
    }


    public String putData(String Url) {


        StringBuilder sb = new StringBuilder();
        for (String key : params.keySet()) {
            String value = null;
            try {
                value = URLEncoder.encode(params.get(key), "UTF-8");
                if (value.contains("+"))
                    value = value.replace("+", "%20");

                //return sb.toString();


                // Get the server response

            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }

            if (sb.length() > 0) {
                sb.append("&");
            }
            sb.append(key + "=" + value);
        }

        try {
            // Defined URL  where to send data

            URL url = new URL(Url);

            URLConnection conn = null;
            conn = url.openConnection();

            // Send PUT data request
            httpConnection = (HttpURLConnection) conn;
            httpConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
            httpConnection.setRequestMethod("PUT");
            httpConnection.setDoInput(true);
            httpConnection.setDoOutput(false);
            OutputStreamWriter wr = null;

            wr = new OutputStreamWriter(conn.getOutputStream());
            wr.write(sb.toString());
            wr.flush();

            reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
            ;
            String line = null;

            // Read Server Response
            while ((line = reader.readLine()) != null) {
                // Append server response in string
                sb1.append(line + " ");
            }

            // Append Server Response To Content String
            Content = sb.toString();


        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {

                reader.close();
            } catch (Exception ex) {
            }
        }
        // Send PUT data request
        return Url;

    }


    public String deleteData(String Url) {


        StringBuilder sb = new StringBuilder();
        for (String key : params.keySet()) {

            try {
                // Defined URL  where to send data

                URL url = new URL(Url);

                URLConnection conn = null;
                conn = url.openConnection();

                // Send POST data request
                httpConnection = (HttpURLConnection) conn;
                httpConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
                httpConnection.setRequestMethod("DELETE");
                httpConnection.connect();


                reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));

                String line = null;

                // Read Server Response
                while ((line = reader.readLine()) != null) {
                    // Append server response in string
                    sb1.append(line + " ");
                }

                // Append Server Response To Content String
                Content = sb.toString();


            } catch (IOException e) {
                e.printStackTrace();
            } finally {
                try {

                    reader.close();
                } catch (Exception ex) {
                }
            }



        }
        return Url;

    }

并像这样使用这个类。此类自动进行互联网连接并给您来自服务器的响应:

    private class ServiceLogin extends AsyncTask<String, Void, String> {

            ProgressDialog mProgressDialog;
            private String res;

            @Override
            protected void onPreExecute() {
                mProgressDialog = ProgressDialog.show(LoginActivity.this,
                        "", "Please wait...");
            }

            @Override
            protected String doInBackground(String... params) {
                res = null;
                PutUtility put = new PutUtility();

                put.setParam("UserId", params[0].toString());
                put.setParam("Latitude", params[1].toString());
                put.setParam("Longitude", params[2].toString());
                put.setParam("DateTime", params[3].toString());

                try {
                    res = put.postData("INSERT URL of API HERE");
                    Log.v("res", res);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                return res;

            }

            protected void onPostExecute(String res) {
                //"Here you get response from server in res"

            }
        }

现在您可以通过单击按钮调用此服务并在服务中插入数据,如下所示:

new ServiceLogin().execute(pass four parameters here);

希望这对您有帮助

EDIT:

这是用于插入数据的简单 PHP Api

<?php include('connection.php');

$return_arr = array();

 $UserId=($_POST['UserId']);
 $Latitude=($_POST['Latitude']);
 $Longitude=($_POST['Longitude']);
$DateTime=($_POST['DateTime']);


        $user_register_sql1 = "INSERT INTO `activity`(`Id`,`UserId`, `Latitude`,`Longitude`,`DateTime`) values (NULL,'".$UserId."','".$Latitude."','".$Longitude."','".$DateTime."')"; 
             mysql_query($user_register_sql1);
             $row_array['errorcode1'] = 1; 

}
?>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何从android发送数据到mysql服务器? 的相关文章

  • 在 android studio 中找不到 SDK 位置

    我刚刚在 android studio 中导入了我的 eclipse 项目 我一直这么说 Error SDK location not found Define location with sdk dir in the local prop
  • 如何将设备屏幕位置转换为发送事件位置?

    我知道关于input tap x yshell 命令 但是 我想了解如何 使用执行单击sendevent命令 我能够通过以下命令实现它 sendevent dev input event5 3 53 X sendevent dev inpu
  • 使用数据库进行日志记录

    大多数日志似乎都是纯文本形式 而不是放入 MySQL 其他类型的数据库中 这是否有原因 在我看来 将它们放入数据库将使分析变得非常非常容易 但这会以牺牲速度还是其他什么为代价 我不太关心可移植性 显然你会有数据库连接的文本日志 我能想到两大
  • 将人类日期(当地时间 GMT)转​​换为日期

    我正在服务器上工作 服务器正在向我发送 GMT 本地日期的日期 例如Fri Jun 22 09 29 29 NPT 2018在字符串格式上 我将其转换为日期 如下所示 SimpleDateFormat simpleDateFormat ne
  • 在 Xamarin 中隐藏软键盘

    如何隐藏软键盘以便在聚焦时显示Entry在 Xamarin forms 便携式表单项目中 我假设我们必须为此编写特定于平台的渲染器 但以下内容不起作用 我创建自己的条目子类 public class MyExtendedEntry Entr
  • PHP MVC 应用程序中哪里可以捕获异常?

    我有一个中小型 PHP 应用程序 用于练习 OOP 和 MVC 技能 我有初始化 引导程序调用的文件Router谁打电话控制器 gt 服务层 gt 存储库 数据库 然后将变量发送回视图层 所有依赖项均由 DiC IOC 处理 我创建抽象类
  • react-native android fontFamily 不生效

    问题一 我在index android js的欢迎样式中添加了fontFamily 但没有效果 fontFamily 真的可以在 Android 上使用吗 欢迎 字体大小 20 fontFamily roboto thin 文本对齐 居中
  • Android:如何创建模态进度“轮”叠加层?

    我想在我的视图上显示模式进度 轮子 叠加层 ProgressDialog 很接近 但我不想要对话框背景或边框 我尝试设置对话框窗口的背景可绘制 this progressDialog new ProgressDialog Main this
  • 为什么 Google 建议将库复制到您的树中?

    谷歌的Play 服务 API 的使用说明 http developer android com google play services setup html 例如 说 将 extras google google play service
  • 访问 Magento 购物车和/或结帐中的运费

    请注意 这个问题是关于运费 而不是价格 有一个重要的区别 即运输方式为店主支付的费用是多少 而不是客户支付的费用 The shipping tablerate数据库表包括一个cost字段 该字段填充在Mage Shipping Model
  • Doctrine2:入门教程“没有要处理的元数据类”

    我已经将本教程的第一部分运行了三遍 到目前为止 在这里或其他地方进行的大量搜索都无法帮助我使其发挥作用 我收到 没有要处理的元数据类 当我尝试时 php vendor bin doctrine orm schema tool update
  • React Native HTTPS Api 调用在 IOS 中有效,但在 Android 中无效

    所以基本上我所做的就是简单地对启用了 HTTPS 的 UAT 服务器进行简单的 Axios 调用 我已经在 IOS 中测试了整个应用程序 API 调用工作正常 但一旦我在 Android 中测试了相同的应用程序 在真正的 Android 设
  • 如何使用 isInEditMode() 在编辑器中查看自定义视图的布局

    我必须编辑一个具有自定义视图的软件 当我尝试编辑布局 xml 时 Eclipse 告诉我 在自定义视图中使用 View isInEditMode 可以在显示时跳过代码 在日食中 但我不知道how and where我必须使用isInEdit
  • 是否可以使用流上下文在 PHP 下使用 FTPS?

    我了解到使用ftpsPHP for Windows 下的 ftp ssl connect 很困难 您被要求进入构建自己的二进制文件以包括 Open SSL 的漫长旅程 我找到了以下建议phpseclib http phpseclib sou
  • 如何解决 greenDAO 在执行 InsertOrReplace 时“不存在这样的表错误”?

    我正在使用 greenDAO 并且已成功生成所有必需的类和实体 并且我可以看到我的表已创建 但是在要替换的行上放置断点后 我收到一条错误消息 告诉我 不存在这样的表错误 try appTimeUsageDao insertOrReplace
  • 通过php将mp3转换为ogg

    我有一个网站 用户可以上传音乐并将其转换为 mp3 但我需要 mp3 和 ogg 文件支持才能以 html5 播放音乐 那么 有没有可以将mp3转换为ogg的php脚本呢 使用 ffmpeg 您可以直接从 php 脚本执行命令
  • Activity 暂停时调用 FragmentManager.popBackStack 是否安全

    的文档FragmentManager popBackStack https developer android com reference android app FragmentManager html popBackStack java
  • Android View Canvas onDraw 未执行

    我目前正在开发一个自定义视图 它在画布上绘制一些图块 这些图块是从多个文件加载的 并将在需要时加载 它们将由 AsyncTask 加载 如果它们已经加载 它们只会被绘制在画布上 这工作正常 如果加载了这些图片 AsyncTask 就会触发v
  • PHP:是否可以从文件内容(字符串)创建 SplFileObject 对象?

    例如 contents file get contents image png 是否可以从 contents 创建 SplFileObject 对象 Thanks php 有一些特殊的流包装器 http www php net manual
  • 合并 csv 文件 [关闭]

    Closed 这个问题不符合堆栈溢出指南 help closed questions 目前不接受答案 如何在 PHP 或 joomla 中将多个 CSV 文件合并为一个 csv 文件 将文件夹中 csv 文件中的所有数据合并到文本文件中 通

随机推荐

  • 使用history.pushState()更新URL中的参数

    我在用history pushState在我的页面上进行 AJAX 调用后 将一些参数附加到当前页面 URL 现在 在基于用户操作的同一页面上 我想使用相同或附加的参数集再次更新页面 URL 所以我的代码如下所示 var pageUrl w
  • 如何使用有状态 LSTM 和 batch_size > 1 布置训练数据

    背景 我想在 Keras 中对 有状态 LSTM 进行小批量训练 我的输入训练数据位于一个大矩阵 X 中 其维度为 m x n 其中 m number of subsequences n number of time steps per s
  • Bokeh - 如何使 HoverTool 工具提示粘在点击点上?

    下面的代码来自于Jupyter笔记本 https nbviewer jupyter org github draperjames PythonRef blob master Bokeh 20HoverTool 20Custom 20Tool
  • 在 Ubuntu 12.04 上为 Perl 5.14.2 LWP 安装新的 ca 证书

    我在尝试使用 LWP 连接到特定 https 网站时收到以下错误 LWP Protocol https Socket SSL connect attempt failed with unknown errorerror 14090086 S
  • 用于计算“该月最后一个星期四”等间隔的工具/库

    我正在寻找一个命令行工具或某种Python库 然后我可以包装 这样我就可以计算指定的日期 例如 该月的最后一个星期四 也就是说 我想让人们输入像上面这样的人类友好文本 并且它应该能够计算任何月 年 任何满足该要求的日期 有什么建议么 mxD
  • Java SSLEngine 示例 [关闭]

    Closed 这个问题正在寻求书籍 工具 软件库等的推荐 不满足堆栈溢出指南 help closed questions 目前不接受答案 我找到了一个如何实现 Java SSLEngine 的示例here http docs oracle
  • Github认为合并后分支不同

    我已经被这个 Github 问题撞到墙上了 终于来到这里寻求帮助 我的repo https github com KAPSARC KTAB有两个感兴趣的分支 master 这是当前实时发布的分支 并且alternate testing 这正
  • Magento 获取 phtml 文件上使用的布局

    有没有办法可以获取某个 phtml 文件使用的布局 就我而言 我想检查catalog list phtml 上使用的布局 我使用该信息对产品图像网格大小进行条件 if 我试着用谷歌搜索一下 但所有的结果只是解释有关 xml 布局的事情 我得
  • Grails 从域验证器获取会话变量

    我确信这是一个常见的情况 但我还没有找到任何答案 我有一个会话范围的变量 用于保存当前登录的用户 我需要通过域对象中的自定义验证器来执行条件验证 有没有办法在验证器中从会话范围中获取当前用户 或者是否有其他方法可以做到这一点 请记住我希望能
  • 子类如何调用与子类的方法名相同的超类的方法?

    include
  • 尝试为每个 Web 请求实现会话,没有当前会话上下文配置

    正如我在标题中所说 我想为每个网络请求实现会话 我的会话提供程序是这样配置的 我对更改此配置不感兴趣 public class SessionProvider public static SessionProvider Instance g
  • 向 Google Cloud Firestore 上传和下载文件

    我看到 Firebase 已经发布了一个新的测试版 名为 Cloud Firestore 在文档中 文档的所有操作都描述得非常好 但我无法找到有关使用 Android 将媒体文件上传和下载到 Cloud Firestore 的任何信息 有人
  • 重写 php 应用程序以获得 seo 友好的 url

    我有 php 应用程序 由于客户要求拥有 SEO 友好的 url 因此必须部分重写 我的链接如下 www mysite com articles en php artid 89 我必须更改其中的网址 www mysite com artic
  • 使用Subject 和Observable 之间有什么区别,各自的用途是什么?

    我了解了制作 Observable 的两种不同方法 第一个是一个主题 如下所示 file A const message new Subject file B message subscribe message gt console log
  • 保留解密加密数据库的解密密钥的最佳方法是什么?

    我有一个加密的数据库和解密密钥 如何使解密密钥免受黑客攻击 数据库黑客攻击和未经授权的 PC 访问 汇编中的硬编码 保存在注册表中 保存在内存中 此外 我需要加密数据的算法 在每个解密时间期限的安全性方面 执行此操作的最佳算法是什么 RSA
  • GNU 日期和自定义格式

    我有一些特定日期格式的字符串 我想使用 GNU date 命令 coreutils 8 20 来处理它们 我可以使用 FORMAT 字符串获取要输出的日期 但不能理解使用相同字符串输入的字符串 我很确定我错过了一些明显的东西 是什么赋予了
  • 函数返回与不返回?

    返回还是不返回 是函数的问题 或者说 这真的很重要吗 故事就这样开始了 我曾经编写如下代码 Type3 myFunc Type1 input1 Type2 input2 但最近我的项目学院告诉我 我应该尽可能避免编写这样的函数 并建议采用以
  • 如何从里程计/tf数据获取投影矩阵?

    我想将视觉里程计的结果与 KITTI 数据集提供的事实进行比较 对于地面中的每一帧 我都有一个投影矩阵 例如 1 000000e 00 9 043683e 12 2 326809e 11 1 110223e 16 9 043683e 12
  • 如何在 MongoDB 中执行 SQL Join 等效操作?

    如何在 MongoDB 中执行 SQL Join 等效操作 例如 假设您有两个集合 用户和评论 我想提取 pid 444 的所有评论以及每个集合的用户信息 comments uid 12345 pid 444 comment blah ui
  • 如何从android发送数据到mysql服务器?

    我是android开发的新手 我正在使用 Android Studio 我正在制作一个应用程序 其中有一个名称下拉列表 选择任何名称后 相应的ID该名称显示在应用程序中 然后有一个按钮将搜索用户当前的 GPS 坐标并将其显示在应用程序上 我