在Android中制作考勤应用程序

问题描述 投票:0回答:2

我必须为大学制作出勤应用程序。该应用程序将从大学网站获取数据,并根据用户登录名和密码将其显示在应用程序上。

当我们登录大学网站时,我们必须将

id
password
放在我的应用程序上,这样用户就可以在应用程序本身上看到它。

我搜索过

httpurlconnection
httpget
httppost
jsoup

到目前为止,我已经明白我必须制作

httprequest
来加载大学的出勤网站,然后制作
httppost
来发布用户名和密码,然后制作
jsoup
来从HTML页面获取数据。

但是我看到的教程只是请求 JSON 页面,但是如何请求 HTML 页面?并登录它?

这是我尝试并从 JSON 收集的数据

private  TextView textresponse1;
private ProgressDialog progressDialog;
@Override
protected void onCreate(Bundle savedInstanceState) {

      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      Button Get= (Button) findViewById(R.id.httprequest);
      textresponse1= (TextView)findViewById(R.id.textresponse);
      progressDialog=new ProgressDialog(this);
      Get.setOnClickListener(this);
}

@Override
public void onClick(View v) {    

      new JSONTask().execute("https://jsonparsingdemo-cec5b.firebaseapp.com/jsonData/moviesDemoList.txt");
      progressDialog.setMessage("Collecting Data");
      progressDialog.show();
 }

public class JSONTask extends AsyncTask<String,String,String >{

    @Override
    protected String doInBackground(String... params) {
        BufferedReader reader = null;
        HttpURLConnection connection = null;
        try {
              URL url=new URL(params[0]);
              connection=(HttpURLConnection) url.openConnection();
              connection.connect();

              InputStream stream=connection.getInputStream();

              reader=new BufferedReader(new InputStreamReader(stream));

              String line="";
              StringBuffer buffer=new StringBuffer();
              while ((line = reader.readLine())!=null) {
                    buffer.append(line);
                }

              String finaljosn=buffer.toString();
              StringBuffer add =new StringBuffer();
              JSONObject parentobject=new JSONObject(finaljosn);
              JSONArray parentarray=parentobject.getJSONArray("movies");
              for(int i=0;i<parentarray.length();i++) {
                   JSONObject moviename = parentarray.getJSONObject(i);

                   String finalmovie = moviename.getString("movie");
                   int finalyear = moviename.getInt("year");
                   add.append(finalmovie +"- "+finalyear + "\n");
               }
                 return add.toString();
              // return finalmovie +" -Rushabh- " +finalyear;

         } catch (MalformedURLException e) {
              e.printStackTrace();
         } catch (IOException e) {
              e.printStackTrace();
         } catch (JSONException e) {
              e.printStackTrace();
         } finally {
              if (connection!=null) {
                  connection.disconnect();
              }
              try {
                    if (reader!=null) {
                        reader.close();
                   }
              } catch (IOException e) {
                    e.printStackTrace();
              }
           }
          return null;
       }

    @Override
    protected void onPostExecute(String result) {
          super.onPostExecute(result);
          progressDialog.dismiss();
          textresponse1.setText(result);
    }
}
java android json http
2个回答
0
投票

 String mLoadURL="http://www.google.com";
 
 public class LoadHtml extends AsyncTask<String, String, String> {

        @Override
        protected String doInBackground(String... params) {
            URL url = null;
            try {
                url = new URL(mLoadURL);
                StringBuilder stringBuilder = new StringBuilder();
                URLConnection conn = url.openConnection();
                // Get the response
                BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
                String line = "";
                while ((line = rd.readLine()) != null) {
                    stringBuilder.append(line);
                }
                return stringBuilder.toString();
            } catch (MalformedURLException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return "";
        }

        @Override
        protected void onPostExecute(String s) {
            super.onPostExecute(s);
             if (!s.trim().isEmpty()) {
               //load html to webview
             }
        }
    }

使用以下方式调用上述 AsyncTask:

LoadHtml loadHtml= new LoadHtml();
load.execute();

0
投票

最佳出席申请

过去,跟踪员工出勤情况要简单得多。公司只会使用基本的时钟来记录员工何时上下班——这也很容易受到伙伴打卡等考勤欺诈的影响。然而,随着技术的进步,考勤管理系统也在进步。 Kyte 使用新的数字功能创建了具有更多功能的工具。他们的系统可以自动实时跟踪工作时间并与您使用的其他商业软件连接。 在此输入链接描述

© www.soinside.com 2019 - 2024. All rights reserved.