add example app source, adjust Docker/Makefile

This commit is contained in:
Alexander Mahr 2024-10-07 16:37:21 +02:00
parent 7fd031d700
commit 8f560f0f61
10 changed files with 293 additions and 4 deletions

View file

@ -28,3 +28,4 @@ RUN chown 0:0 /entrypoint.sh
RUN chmod 0700 /entrypoint.sh
WORKDIR /apk
ENTRYPOINT ["/entrypoint.sh"]
RUN echo "$YESACCEPT" | tee yesaccept

View file

@ -1,8 +1,12 @@
all: build install
build:
docker-compose run compile
install:
adb install -r ./apk/bin/app1.apk
clean:
rm docker-compose-build.log || true

View file

@ -8,15 +8,12 @@ CXX_FLAGS = -march=armv8-a --sysroot=$(TOOLCHAIN)/sysroot
all: build deploy
all: build
.PHONY : build
.PHONY : deploy
.PHONY : clean
deploy :
adb install -r ./bin/hellojni.apk
build : ./bin/app1.apk

View file

@ -0,0 +1,117 @@
package de.alexmahr.app1;
import android.util.Log;
import android.widget.TextView;
import android.app.Activity;
import android.os.Bundle;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.lang.Thread;
import java.util.concurrent.TimeUnit;
import android.text.method.ScrollingMovementMethod;
class Threads1 implements Runnable {
public String result = "alex";
public void run(){
try{
result = result.concat("step 2\n");
URL url = new URL("https://alexmahr.de/word");
result = result.concat("step 3\n");
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
result = result.concat("step 4\n");
BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
result = result.concat("step 5\n");
String inputLine;
StringBuffer response = new StringBuffer();
result = result.concat("step 6\n");
while ((inputLine = in.readLine()) != null) {
result = result.concat("step 7\n");
response.append(inputLine);
}
result = result.concat("step 8\n");
in.close();
result = result.concat("step 9\n");
result = result.concat( "OK".concat(response.toString()));
urlConnection.disconnect();
} catch (Exception e){
// throw new RuntimeException(e);
}
}
}
public class App1 extends Activity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
try
{
super.onCreate(savedInstanceState);
//volatile String result = "initial";
String result = "initial";
TextView tv = new TextView(this);
tv.setMovementMethod(new ScrollingMovementMethod());
Threads1 threads1 = new Threads1();
Thread thread = new Thread(threads1);
thread.start();
thread.join();
// Thread thread = new Thread(new Runnable() {
// @Override
// public void run() {
// try {
// result = result.concat("step 2\n");
// URL url = new URL("https://alexmahr.de/word");
// result = result.concat("step 3\n");
// HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
// result = result.concat("step 4\n");
// BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
// result = result.concat("step 5\n");
// String inputLine;
// StringBuffer response = new StringBuffer();
// result = result.concat("step 6\n");
// while ((inputLine = in.readLine()) != null) {
// result = result.concat("step 7\n");
// response.append(inputLine);
// }
// result = result.concat("step 8\n");
// in.close();
// result = result.concat("step 9\n");
// result = result.concat( "OK".concat(response.toString()));
// urlConnection.disconnect();
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
// });
// thread.start();
// thread.join();
tv.setText( result);
setContentView(tv);
try{
// TimeUnit.SECONDS.sleep(1);
} catch (Exception e){
// throw new RuntimeException(e);
}
tv.setText(result.concat(threads1.result));
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}

View file

@ -0,0 +1,47 @@
import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
// calling this activity's function to
// use ActionBar utility methods
val actionBar = supportActionBar
// providing title for the ActionBar
actionBar!!.title = " GfG | Action Bar"
// providing subtitle for the ActionBar
actionBar.subtitle = " Design a custom Action Bar"
// adding icon in the ActionBar
actionBar.setIcon(R.drawable.app_logo)
// methods to display the icon in the ActionBar
actionBar.setDisplayUseLogoEnabled(true)
actionBar.setDisplayShowHomeEnabled(true)
}
// method to inflate the options menu when
// the user opens the menu for the first time
override fun onCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(R.menu.main, menu)
return super.onCreateOptionsMenu(menu)
}
// methods to control the operations that will
// happen when user clicks on the action buttons
override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
R.id.search -> Toast.makeText(this, "Search Clicked", Toast.LENGTH_SHORT).show()
R.id.refresh -> Toast.makeText(this, "Refresh Clicked", Toast.LENGTH_SHORT).show()
R.id.copy -> Toast.makeText(this, "Copy Clicked", Toast.LENGTH_SHORT).show()
}
return super.onOptionsItemSelected(item)
}
}

View file

@ -0,0 +1,93 @@
package de.alexmahr.app1;
//#import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.util.Log;
import android.widget.TextView;
import android.app.Activity;
//import java.io.BufferedReader;
//import java.io.IOException;
//import java.io.InputStreamReader;
//import java.io.OutputStream;
//import java.net.HttpURLConnection;
//import java.net.URL;
//import java.lang.Thread;
//import java.util.concurrent.TimeUnit;
//import android.text.method.ScrollingMovementMethod;
public class App1 extends Activity{
{
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState);
val tv = TextView(this);
tv.setText( "result");
setContentView(tv);
}
}
// @Override
// public void onCreate(Bundle savedInstanceState)
// {
// try
// {
// super.onCreate(savedInstanceState);
// //volatile String result = "initial";
// String result = "initial";
// TextView tv = new TextView(this);
// tv.setMovementMethod(new ScrollingMovementMethod());
// Threads1 threads1 = new Threads1();
// Thread thread = new Thread(threads1);
// thread.start();
// thread.join();
//
// // Thread thread = new Thread(new Runnable() {
//
// // @Override
// // public void run() {
// // try {
// // result = result.concat("step 2\n");
// // URL url = new URL("https://alexmahr.de/word");
// // result = result.concat("step 3\n");
// // HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
// // result = result.concat("step 4\n");
// // BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
// // result = result.concat("step 5\n");
// // String inputLine;
// // StringBuffer response = new StringBuffer();
// // result = result.concat("step 6\n");
//
// // while ((inputLine = in.readLine()) != null) {
// // result = result.concat("step 7\n");
// // response.append(inputLine);
// // }
// // result = result.concat("step 8\n");
// // in.close();
// // result = result.concat("step 9\n");
// // result = result.concat( "OK".concat(response.toString()));
// // urlConnection.disconnect();
//
//
// // } catch (Exception e) {
// // e.printStackTrace();
// // }
// // }
// // });
// // thread.start();
// // thread.join();
// tv.setText( result);
// setContentView(tv);
// try{
// // TimeUnit.SECONDS.sleep(1);
// } catch (Exception e){
//// throw new RuntimeException(e);
// }
// tv.setText(result.concat(threads1.result));
// } catch (Exception e) {
// throw new RuntimeException(e);
// }
//
// }
//
//
//}

View file

@ -0,0 +1,22 @@
/* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
* aapt tool from the resource data it found. It
* should not be modified by hand.
*/
package de.alexmahr.app1;
public final class R {
public static final class attr {
}
public static final class drawable {
public static final int ic_launcher=0x7f020000;
}
public static final class layout {
public static final int main=0x7f030000;
}
public static final class string {
public static final int app_name=0x7f040000;
}
}

BIN
apk/src/main Executable file

Binary file not shown.

6
apk/src/main.c Normal file
View file

@ -0,0 +1,6 @@
#include<stdio.h>
int main(){
printf("hallo");
return 0;
}

View file

@ -2,6 +2,8 @@ services:
compile:
build:
context: .
args:
YESACCEPT: ${YESACCEPT}
stop_grace_period: 1s
volumes:
- ./apk:/apk