From e5d7c9c156c428d1cbe93ffdc556fe331661ffe0 Mon Sep 17 00:00:00 2001 From: gialexpro Date: Sat, 27 May 2023 09:58:00 +0300 Subject: [PATCH] upload android code --- android/UDPtest000/.gitignore | 15 ++ android/UDPtest000/.idea/.gitignore | 3 + android/UDPtest000/.idea/compiler.xml | 6 + android/UDPtest000/.idea/gradle.xml | 20 ++ android/UDPtest000/.idea/misc.xml | 9 + android/UDPtest000/app/.gitignore | 1 + android/UDPtest000/app/build.gradle | 39 ++++ android/UDPtest000/app/proguard-rules.pro | 21 ++ .../udptest000/ExampleInstrumentedTest.java | 26 +++ .../app/src/main/AndroidManifest.xml | 27 +++ .../main/java/com/example/udptest000 (1).zip | Bin 0 -> 1408 bytes .../main/java/com/example/udptest000 (2).zip | Bin 0 -> 2854 bytes .../src/main/java/com/example/udptest000.zip | Bin 0 -> 1329 bytes .../com/example/udptest000/MainActivity.java | 52 +++++ .../com/example/udptest000/TrackpadView.java | 171 ++++++++++++++++ .../com/example/udptest000/UDP_Client.java | 87 ++++++++ .../drawable-v24/ic_launcher_foreground.xml | 30 +++ .../res/drawable/ic_launcher_background.xml | 170 ++++++++++++++++ .../app/src/main/res/layout/activity_main.xml | 40 ++++ .../res/mipmap-anydpi-v26/ic_launcher.xml | 6 + .../mipmap-anydpi-v26/ic_launcher_round.xml | 6 + .../src/main/res/mipmap-hdpi/ic_launcher.webp | Bin 0 -> 1404 bytes .../res/mipmap-hdpi/ic_launcher_round.webp | Bin 0 -> 2898 bytes .../src/main/res/mipmap-mdpi/ic_launcher.webp | Bin 0 -> 982 bytes .../res/mipmap-mdpi/ic_launcher_round.webp | Bin 0 -> 1772 bytes .../main/res/mipmap-xhdpi/ic_launcher.webp | Bin 0 -> 1900 bytes .../res/mipmap-xhdpi/ic_launcher_round.webp | Bin 0 -> 3918 bytes .../main/res/mipmap-xxhdpi/ic_launcher.webp | Bin 0 -> 2884 bytes .../res/mipmap-xxhdpi/ic_launcher_round.webp | Bin 0 -> 5914 bytes .../main/res/mipmap-xxxhdpi/ic_launcher.webp | Bin 0 -> 3844 bytes .../res/mipmap-xxxhdpi/ic_launcher_round.webp | Bin 0 -> 7778 bytes .../app/src/main/res/values-night/themes.xml | 7 + .../app/src/main/res/values/colors.xml | 5 + .../app/src/main/res/values/strings.xml | 3 + .../app/src/main/res/values/themes.xml | 9 + .../app/src/main/res/xml/backup_rules.xml | 13 ++ .../main/res/xml/data_extraction_rules.xml | 19 ++ .../example/udptest000/ExampleUnitTest.java | 17 ++ android/UDPtest000/build.gradle | 5 + android/UDPtest000/gradle.properties | 21 ++ .../gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 59203 bytes .../gradle/wrapper/gradle-wrapper.properties | 6 + android/UDPtest000/gradlew | 185 ++++++++++++++++++ android/UDPtest000/gradlew.bat | 89 +++++++++ android/UDPtest000/settings.gradle | 16 ++ 45 files changed, 1124 insertions(+) create mode 100644 android/UDPtest000/.gitignore create mode 100644 android/UDPtest000/.idea/.gitignore create mode 100644 android/UDPtest000/.idea/compiler.xml create mode 100644 android/UDPtest000/.idea/gradle.xml create mode 100644 android/UDPtest000/.idea/misc.xml create mode 100644 android/UDPtest000/app/.gitignore create mode 100644 android/UDPtest000/app/build.gradle create mode 100644 android/UDPtest000/app/proguard-rules.pro create mode 100644 android/UDPtest000/app/src/androidTest/java/com/example/udptest000/ExampleInstrumentedTest.java create mode 100644 android/UDPtest000/app/src/main/AndroidManifest.xml create mode 100644 android/UDPtest000/app/src/main/java/com/example/udptest000 (1).zip create mode 100644 android/UDPtest000/app/src/main/java/com/example/udptest000 (2).zip create mode 100644 android/UDPtest000/app/src/main/java/com/example/udptest000.zip create mode 100644 android/UDPtest000/app/src/main/java/com/example/udptest000/MainActivity.java create mode 100644 android/UDPtest000/app/src/main/java/com/example/udptest000/TrackpadView.java create mode 100644 android/UDPtest000/app/src/main/java/com/example/udptest000/UDP_Client.java create mode 100644 android/UDPtest000/app/src/main/res/drawable-v24/ic_launcher_foreground.xml create mode 100644 android/UDPtest000/app/src/main/res/drawable/ic_launcher_background.xml create mode 100644 android/UDPtest000/app/src/main/res/layout/activity_main.xml create mode 100644 android/UDPtest000/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml create mode 100644 android/UDPtest000/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml create mode 100644 android/UDPtest000/app/src/main/res/mipmap-hdpi/ic_launcher.webp create mode 100644 android/UDPtest000/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp create mode 100644 android/UDPtest000/app/src/main/res/mipmap-mdpi/ic_launcher.webp create mode 100644 android/UDPtest000/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp create mode 100644 android/UDPtest000/app/src/main/res/mipmap-xhdpi/ic_launcher.webp create mode 100644 android/UDPtest000/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp create mode 100644 android/UDPtest000/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp create mode 100644 android/UDPtest000/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp create mode 100644 android/UDPtest000/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp create mode 100644 android/UDPtest000/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp create mode 100644 android/UDPtest000/app/src/main/res/values-night/themes.xml create mode 100644 android/UDPtest000/app/src/main/res/values/colors.xml create mode 100644 android/UDPtest000/app/src/main/res/values/strings.xml create mode 100644 android/UDPtest000/app/src/main/res/values/themes.xml create mode 100644 android/UDPtest000/app/src/main/res/xml/backup_rules.xml create mode 100644 android/UDPtest000/app/src/main/res/xml/data_extraction_rules.xml create mode 100644 android/UDPtest000/app/src/test/java/com/example/udptest000/ExampleUnitTest.java create mode 100644 android/UDPtest000/build.gradle create mode 100644 android/UDPtest000/gradle.properties create mode 100644 android/UDPtest000/gradle/wrapper/gradle-wrapper.jar create mode 100644 android/UDPtest000/gradle/wrapper/gradle-wrapper.properties create mode 100755 android/UDPtest000/gradlew create mode 100644 android/UDPtest000/gradlew.bat create mode 100644 android/UDPtest000/settings.gradle diff --git a/android/UDPtest000/.gitignore b/android/UDPtest000/.gitignore new file mode 100644 index 0000000..aa724b7 --- /dev/null +++ b/android/UDPtest000/.gitignore @@ -0,0 +1,15 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/android/UDPtest000/.idea/.gitignore b/android/UDPtest000/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/android/UDPtest000/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/android/UDPtest000/.idea/compiler.xml b/android/UDPtest000/.idea/compiler.xml new file mode 100644 index 0000000..b589d56 --- /dev/null +++ b/android/UDPtest000/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/android/UDPtest000/.idea/gradle.xml b/android/UDPtest000/.idea/gradle.xml new file mode 100644 index 0000000..239e8d2 --- /dev/null +++ b/android/UDPtest000/.idea/gradle.xml @@ -0,0 +1,20 @@ + + + + + + + \ No newline at end of file diff --git a/android/UDPtest000/.idea/misc.xml b/android/UDPtest000/.idea/misc.xml new file mode 100644 index 0000000..a8a2b16 --- /dev/null +++ b/android/UDPtest000/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/android/UDPtest000/app/.gitignore b/android/UDPtest000/app/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/android/UDPtest000/app/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/android/UDPtest000/app/build.gradle b/android/UDPtest000/app/build.gradle new file mode 100644 index 0000000..1c2232b --- /dev/null +++ b/android/UDPtest000/app/build.gradle @@ -0,0 +1,39 @@ +plugins { + id 'com.android.application' +} + +android { + namespace 'com.example.udptest000' + compileSdk 33 + + defaultConfig { + applicationId "com.example.udptest000" + minSdk 30 + targetSdk 33 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + + implementation 'androidx.appcompat:appcompat:1.4.1' + implementation 'com.google.android.material:material:1.5.0' + implementation 'androidx.constraintlayout:constraintlayout:2.1.3' + testImplementation 'junit:junit:4.13.2' + androidTestImplementation 'androidx.test.ext:junit:1.1.3' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' +} \ No newline at end of file diff --git a/android/UDPtest000/app/proguard-rules.pro b/android/UDPtest000/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/android/UDPtest000/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/android/UDPtest000/app/src/androidTest/java/com/example/udptest000/ExampleInstrumentedTest.java b/android/UDPtest000/app/src/androidTest/java/com/example/udptest000/ExampleInstrumentedTest.java new file mode 100644 index 0000000..fe7d6d5 --- /dev/null +++ b/android/UDPtest000/app/src/androidTest/java/com/example/udptest000/ExampleInstrumentedTest.java @@ -0,0 +1,26 @@ +package com.example.udptest000; + +import android.content.Context; + +import androidx.test.platform.app.InstrumentationRegistry; +import androidx.test.ext.junit.runners.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.junit.Assert.*; + +/** + * Instrumented test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); + assertEquals("com.example.udptest000", appContext.getPackageName()); + } +} \ No newline at end of file diff --git a/android/UDPtest000/app/src/main/AndroidManifest.xml b/android/UDPtest000/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..e6f57f9 --- /dev/null +++ b/android/UDPtest000/app/src/main/AndroidManifest.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/android/UDPtest000/app/src/main/java/com/example/udptest000 (1).zip b/android/UDPtest000/app/src/main/java/com/example/udptest000 (1).zip new file mode 100644 index 0000000000000000000000000000000000000000..78a81647c3603c664eaf46343e9a1037549dbe4d GIT binary patch literal 1408 zcmWIWW@Zs#00D!IyTZT>D8UV+OH&F;Qj1Fr3=H%GzzUfdI2c5L3cqH34?f4l!0?}w zfk6sYVW>+$ymL-wYF>$6R$^J=-mqx@+XfO{yDe7+BD3UTmW9h{i-4Qpwd0S_C96#e~vgnzj^H0b0DI8m# z^h8-*EU_whX!u$0W&5V6`^Eiy$(a@H>n26ZxeF9#@x;vMJ+|D&E%D(_#ym~g^DA6W z{B+3wkX_E9^l(q?2AL??Zcd-Mc5lxrnw+0l%qbgxCrr5O+iNfTyB4L~o1P0^2r=)w zR1@ZBcQdp{->ywNX{F6MbJL8tN6GF-&l?o9i;~2g*I~OoPN&6!%!4 zT6rn-jpl|m- zKH=9rLBe~hZ|${1bKib7JAUx0PJCj{gw&`rA9mO~uT5@aU3uwJQp!Z#y^Sa5Sro?3 z$(XsrbE%ONhsGz?yByXPeiCE0UkVE8Iv^%xicQ!e|{-%HAB4A?f16(tv&|5eah#!GwMO$wS7((GyEkqPj9mE z^m!YrFd>XR{Y#+7d&$?T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^Qx)P(hBYF?Fy} zwdn{3^+beRC&{vjtMOTpukaia*;-D4UkY+0Zjc_if2`i}mBG2^ju_bO?qTvbC!O6v zWw)LRrsaBqIJO^7-U+`sTlkm`Of#7Avx8p@=iCas)WrF;Lf+&m+iZ}w@cS@7c3Zx; zFNPO)nn3(#C2&vT*K!yaXdgm%-^)uUanD>i(KzF&$HdiEF)Pnfob?tjxamZ?<(0Pe zv8+_3%zVC}70qG;KXO!$<=?~KA2|?k2>bf_E(-p)@!!JWpN&uAPC%gs)2f v50if>xd6W#;cw9VyUyS3_CGot-|76rd^T_(+t+H=FZ<*d!ybGAHURJ+a?Tr# literal 0 HcmV?d00001 diff --git a/android/UDPtest000/app/src/main/java/com/example/udptest000.zip b/android/UDPtest000/app/src/main/java/com/example/udptest000.zip new file mode 100644 index 0000000000000000000000000000000000000000..3293656293aa209ede569ed2bd0bb73161b04a6d GIT binary patch literal 1329 zcmWIWW@Zs#00Hj}yTZT>D8UV+OH&F;Qj1Fr3=H%GzzUfdI2e{M*%fwbhmw6Q69dCv zHU zm#sAV7HAZ6d(&K})?fDvA6-yWG5Dic^#1A2=kIF5eQz?yDi~~4`Qb7>O5x;=vW&a` z{?+Zj>^VJ3l0Bqoagg7NDW?LbYk5xc$!@+Dx8%~-`?oZ`*~)Zp_S|YWdzv|oYhUw! z_wXqmB`F@Vu@bxHRK@LR&V3<#b)Ee0^9`TpOn1M2bFGJ@f#cfN*AGkT)Pkn)&9i>c zZ}zgws-=s+XZiZ=$rEM@{GFBh$VW?j!hhuE z{T);9m9{h;N@+c|L?$~ZcZ&0~3F7w-T#cCb>z;1UDVxbLZXArhwdZqUKCfB)eEGeY z2fNiweC9@)r}!TDb7!6Gzn|PI&q+rwlTSG>@N~KaU*Enj+rA&p-&^o^*W}z^YcE`F zcV@0~brE~vcl~L<#*zNpjZVwvMeJp|c=6%Iht_&u9U0f%cf6KAp}981ZvBCa{?#Ji z7icOoJw0^yd)J$)4~(*TonQ0Z0?(}|ooFmsm-6a9+jU*G*=;R>$KNSR*&1H?d5^Kj z{${009p6&#IsTPt8i!v5GrkYzn3n&HS#DeXwQI+B3IqnyRwJ zrlq7tzxBC4^GZ^%hGpor-gy&J`MMpydYB2nvk%TP?rpoW*ZcVPhugQGVtD>lYnuH| z$yn9LCsjS$?4LhAEjdT#@Il9z*sy={D-X;+A>c7HWA}~|Z~kPNNSs?f`Q*`>FV!Vw zwzFeGB^GSB(e^d!rEmJ>N=8JYowayZSnGs{SPMo5hBRQpl|fCkzKNN6j>#pNWtk98nP;v%6L4 zvP70T*TY2-*TSaHxUZzXnBSvE$nvyP{Cn@k4pWWXBD|C9eHhQTgt^b?X;Hhg@_pDX?xbBg-^vB;PKKmz^sz+?oKC5)kkKf>Pn^wi4 zV`6(&KHl7E!{L1Ez~93f`QiEg`qpZNd=h<@5jMT=E(dlkta4amcX53uU1mi(iC@~L!yHzSihGwu=vTDUO$bp)|c$`^=6TqO)l { + UDP_Client Client = new UDP_Client(); + Client.Message = "HW"; + Client.Send(); + }); + + left.setOnTouchListener(new View.OnTouchListener() { + @Override + public boolean onTouch(View v, MotionEvent event) { + UDP_Client Client = new UDP_Client(); + switch(event.getAction()) { + case MotionEvent.ACTION_DOWN: + Client.Message = "BLD"; + break; + case MotionEvent.ACTION_UP: + Client.Message = "BLU"; + } + if(Client.Message!=null) { + Client.Send(); + return true; + } + return false; + } + }); + } +} \ No newline at end of file diff --git a/android/UDPtest000/app/src/main/java/com/example/udptest000/TrackpadView.java b/android/UDPtest000/app/src/main/java/com/example/udptest000/TrackpadView.java new file mode 100644 index 0000000..28badbe --- /dev/null +++ b/android/UDPtest000/app/src/main/java/com/example/udptest000/TrackpadView.java @@ -0,0 +1,171 @@ +package com.example.udptest000; + +import android.content.Context; +import android.graphics.Bitmap; +import android.graphics.Canvas; +import android.graphics.Color; +import android.graphics.Paint; +import android.graphics.Path; +import android.graphics.PointF; +import android.view.MotionEvent; +import android.view.View; + +public class TrackpadView extends View { + + private final Paint mPaint; + private Bitmap mBitmap; + private final Path mPath; + private final Paint mBitmapPaint; + final int CLICK = 3; + Canvas canvas; + PointF start = new PointF(); + long downStart = 0; + boolean touching = false; + + // coordinate rounding errors + private float reX = 0; + private float reY = 0; + + + public TrackpadView(Context c) { + super(c); + + mPaint = new Paint(); + mPaint.setAntiAlias(true); + mPaint.setDither(true); + + mPaint.setStyle(Paint.Style.STROKE); + mPaint.setStrokeJoin(Paint.Join.ROUND); + mPaint.setStrokeCap(Paint.Cap.ROUND); + + mPath = new Path(); + mBitmapPaint = new Paint(Paint.DITHER_FLAG); + } + + @Override + protected void onSizeChanged(int w, int h, int oldw, int oldh) { + super.onSizeChanged(w, h, oldw, oldh); + mBitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888); + + } + + @Override + protected void onDraw(Canvas c) { + canvas=c; + canvas.drawBitmap(mBitmap, 0, 0, mBitmapPaint); + + mPaint.setColor(Color.BLUE); + mPaint.setStrokeWidth(3); + + mPaint.setStrokeWidth(10); + canvas.drawPath(mPath, mPaint); + + if(touching) { + mPaint.setColor(Color.BLACK); + + canvas.drawCircle(mX, mY, 80, mPaint); + + } + + + } + + private float mX=0; + private float mY=0; + private final float TOUCH_TOLERANCE = 4; + private PointF curr; + + private void touch_start(float x, float y) { + touching=true; + + + mPath.reset(); + mPath.moveTo(x, y); + mX = x; + mY = y; + + } + private void touch_move(float x, float y, boolean silent) { + + + + + float rx = x - mX; + float ry = y - mY; + float dx = Math.abs(rx); + float dy = Math.abs(ry); + + + if (dx >= TOUCH_TOLERANCE || dy >= TOUCH_TOLERANCE) { + if(!silent) mPath.quadTo(mX, mY, (x+mX)/2, (y+mY)/2); + mX = x; + mY = y; + + + UDP_Client Client = new UDP_Client(); + int frx= (int) rx; + int fry= (int) ry; + Client.Message = "MRX"+frx+"Y"+fry; + Client.Send(); + } + + + } + private void touch_up() { + mPath.lineTo(mX, mY); + // kill this so we don't double draw + mPath.reset(); + touching=false; + } + + + @Override + public boolean onTouchEvent(MotionEvent event) { + float x = event.getX(); + float y = event.getY(); + curr = new PointF(event.getX(), event.getY()); + double newDist = 0; + + + switch (event.getAction()) { + case MotionEvent.ACTION_DOWN: + + downStart = System.currentTimeMillis(); + start.set(curr); + touch_start(x, y); + + invalidate(); + break; + case MotionEvent.ACTION_MOVE: + + int xDiff1 = (int) Math.abs(curr.x - start.x); + int yDiff1 = (int) Math.abs(curr.y - start.y); + + + //Log.d("onTouchEvent",xDiff1+" "+yDiff1+" "+CLICK); + long thisTime = System.currentTimeMillis() - downStart; + + touch_move(x, y, false); + + invalidate(); + break; + case MotionEvent.ACTION_UP: + + int xDiff = (int) Math.abs(curr.x - start.x); + int yDiff = (int) Math.abs(curr.y - start.y); + if (xDiff < CLICK && yDiff < CLICK) { + + UDP_Client Client = new UDP_Client(); + Client.Message = "CL"; + Client.Send(); + + } + + touch_up(); + invalidate(); + + break; + } + return true; + } +} \ No newline at end of file diff --git a/android/UDPtest000/app/src/main/java/com/example/udptest000/UDP_Client.java b/android/UDPtest000/app/src/main/java/com/example/udptest000/UDP_Client.java new file mode 100644 index 0000000..35e45e7 --- /dev/null +++ b/android/UDPtest000/app/src/main/java/com/example/udptest000/UDP_Client.java @@ -0,0 +1,87 @@ +package com.example.udptest000; + +import android.annotation.SuppressLint; +import android.os.AsyncTask; + +import java.net.DatagramPacket; +import java.net.DatagramSocket; +import java.net.InetAddress; + +public class UDP_Client { + private InetAddress IPAddress = null; + private String message = "OO" ; + private AsyncTask async_cient; + public String Message; + + + @SuppressLint("NewApi") + public void Send() + { + new Thread(() -> { + DatagramSocket ds = null; + + try + { + byte[] ipAddr = new byte[]{ (byte) 192, (byte) 168,(byte)4, (byte) 1}; + InetAddress addr = InetAddress.getByAddress(ipAddr); + ds = new DatagramSocket(9696); + DatagramPacket dp; + dp = new DatagramPacket(Message.getBytes(), Message.getBytes().length, addr, 9696); + ds.setBroadcast(true); + ds.send(dp); + } + catch (Exception e) + { + e.printStackTrace(); + } + finally + { + if (ds != null) + { + ds.close(); + } + } + }).start(); + + /* + async_cient = new AsyncTask() + { + @Override + protected Void doInBackground(Void... params) + { + DatagramSocket ds = null; + + try + { + byte[] ipAddr = new byte[]{ (byte) 192, (byte) 168,(byte)4, (byte) 1}; + InetAddress addr = InetAddress.getByAddress(ipAddr); + ds = new DatagramSocket(9696); + DatagramPacket dp; + dp = new DatagramPacket(Message.getBytes(), Message.getBytes().length, addr, 9696); + ds.setBroadcast(true); + ds.send(dp); + } + catch (Exception e) + { + e.printStackTrace(); + } + finally + { + if (ds != null) + { + ds.close(); + } + } + return null; + } + + protected void onPostExecute(Void result) + { + super.onPostExecute(result); + } + }; + + if (Build.VERSION.SDK_INT >= 11) async_cient.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); + else async_cient.execute();*/ + } +} diff --git a/android/UDPtest000/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/android/UDPtest000/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/android/UDPtest000/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/android/UDPtest000/app/src/main/res/drawable/ic_launcher_background.xml b/android/UDPtest000/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/android/UDPtest000/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/android/UDPtest000/app/src/main/res/layout/activity_main.xml b/android/UDPtest000/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..e19bd4e --- /dev/null +++ b/android/UDPtest000/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,40 @@ + + + +