Advertisement
Guest User

Untitled

a guest
Sep 28th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.41 KB | None | 0 0
  1. class makePOST extends AsyncTask<String, Void, Double> {
  2. int duration = Toast.LENGTH_SHORT;
  3. @Override
  4. protected void onPreExecute() {
  5. Toast.makeText(update.this, "onPreExecute", Toast.LENGTH_LONG).show();
  6. }
  7. protected Double doInBackground(String... params) {
  8. try {
  9. url = new URL("http://student.96.lt/Android/update.php");
  10. conn = (HttpURLConnection) url.openConnection();
  11. conn.setDoOutput(true);
  12. conn.setDoInput(true);
  13. conn.setRequestMethod("POST");
  14. String postdat = "code" + "=" + URLEncoder.encode(mCode, "UTF-8") + "&" + "latitude" + "=" + URLEncoder.encode(mLatitudeText, "UTF-8") + "&" + "longitude" + "=" + URLEncoder.encode(mLongitudeText, "UTF-8");
  15. //String postdat=mLatitudeText;
  16. conn.setFixedLengthStreamingMode(postdat.getBytes().length);
  17. conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
  18. OutputStream OS = conn.getOutputStream();
  19. InputStream in = conn.getInputStream();
  20.  
  21. BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(OS, "UTF-8"));
  22. bufferedWriter.write(postdat);
  23. bufferedWriter.flush();
  24. // Get output
  25. BufferedReader br = new BufferedReader(new InputStreamReader(in));
  26. StringBuilder sb = new StringBuilder();
  27. String line;
  28. while ((line = br.readLine()) != null) {
  29. sb.append(line);
  30. sb.append("n");
  31. }
  32.  
  33. in.close();
  34. bufferedWriter.close();
  35. // java.io.BufferedOutputStream out = new java.io.BufferedOutputStream(conn.getOutputStream());
  36. // PrintStream pstream = new PrintStream(out);
  37. // pstream.print(postdat);
  38. // pstream.close();
  39. } catch (java.net.MalformedURLException ex) {
  40. //Toast.makeText(this, ex.toString(), duration ).show();
  41. } catch (java.io.IOException ex) {
  42. //Toast.makeText(this, ex.toString(), duration).show();
  43. }
  44. return null;
  45. }
  46.  
  47. };
  48.  
  49. <?php
  50. include 'connect.php';
  51. $m_lat=$_POST['latitude'];
  52. $m_lng=$_POST['longitude'];
  53. $m_code=$_POST['code'];
  54. $query="update `location` set `longitude`='$m_lng',`latitude`='$m_lat' where `code`='$m_code';";
  55. mysqli_query($connect,$query);
  56. mysqli_close($connect);
  57. ?>
  58.  
  59. <?xml version="1.0" encoding="utf-8"?>
  60. <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  61. package="com.project.nikhil.gpslocation">
  62. <permission
  63. android:name="com.javapapers.currentlocationinmap.permission.MAPS_RECEIVE"
  64. android:protectionLevel="signature" />
  65.  
  66. <uses-permission android:name="com.javapapers.currentlocationinmap.permission.MAPS_RECEIVE" />
  67. <uses-permission android:name="android.permission.INTERNET" />
  68. <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
  69. <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
  70.  
  71. <uses-feature
  72. android:glEsVersion="0x00020000"
  73. android:required="true" />
  74.  
  75. <application
  76. android:allowBackup="true"
  77. android:icon="@mipmap/ic_launcher"
  78. android:label="@string/app_name"
  79. android:supportsRtl="true"
  80. android:theme="@style/AppTheme">
  81. <uses-feature
  82. android:name="android.hardware.location.gps"
  83. android:glEsVersion="0x00020000"
  84. android:required="true" />
  85.  
  86. <uses-permission android:name="android.permission.INTERNET" />
  87. <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
  88. <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
  89. <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
  90.  
  91. <meta-data
  92. android:name="com.google.android.gms.version"
  93. android:value="@integer/google_play_services_version" />
  94. <meta-data
  95. android:name="com.google.android.maps.v2.API_KEY"
  96. android:value="MyKey" />
  97. <activity
  98. android:name=".update"
  99. android:label="@string/title_activity_update"
  100. android:exported="true"
  101. android:theme="@style/AppTheme.NoActionBar">
  102. <intent-filter>
  103. <action android:name="android.intent.action.MAIN" />
  104.  
  105. <category android:name="android.intent.category.LAUNCHER" />
  106. </intent-filter>
  107. </activity>
  108. </application>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement