|
|
|
|
|
|
|
|
import static android.content.ContentValues.TAG; |
|
|
import static android.content.ContentValues.TAG; |
|
|
|
|
|
|
|
|
import android.annotation.SuppressLint; |
|
|
import android.annotation.SuppressLint; |
|
|
|
|
|
import android.content.ComponentName; |
|
|
|
|
|
import android.content.Context; |
|
|
|
|
|
import android.content.Intent; |
|
|
|
|
|
import android.content.ServiceConnection; |
|
|
import android.net.wifi.WifiInfo; |
|
|
import android.net.wifi.WifiInfo; |
|
|
import android.net.wifi.WifiManager; |
|
|
import android.net.wifi.WifiManager; |
|
|
import android.net.wifi.WifiInfo; |
|
|
import android.net.wifi.WifiInfo; |
|
|
import android.net.wifi.WifiManager; |
|
|
import android.net.wifi.WifiManager; |
|
|
import android.os.Bundle; |
|
|
import android.os.Bundle; |
|
|
|
|
|
import android.os.IBinder; |
|
|
import android.util.Log; |
|
|
import android.util.Log; |
|
|
import android.view.MenuItem; |
|
|
import android.view.MenuItem; |
|
|
import android.widget.Toast; |
|
|
import android.widget.Toast; |
|
|
|
|
|
|
|
|
import android.widget.TextView; |
|
|
import android.widget.TextView; |
|
|
import android.widget.Toast; |
|
|
import android.widget.Toast; |
|
|
|
|
|
|
|
|
|
|
|
import androidx.annotation.NonNull; |
|
|
import androidx.appcompat.app.AppCompatActivity; |
|
|
import androidx.appcompat.app.AppCompatActivity; |
|
|
|
|
|
import androidx.camera.core.ExperimentalGetImage; |
|
|
|
|
|
|
|
|
|
|
|
import com.example.ueberwachungssystem.Detection.DetectionReport; |
|
|
|
|
|
import com.example.ueberwachungssystem.Detection.DetectorService; |
|
|
|
|
|
|
|
|
import java.net.InetAddress; |
|
|
import java.net.InetAddress; |
|
|
import java.net.UnknownHostException; |
|
|
import java.net.UnknownHostException; |
|
|
import java.nio.ByteBuffer; |
|
|
import java.nio.ByteBuffer; |
|
|
import java.nio.ByteOrder; |
|
|
import java.nio.ByteOrder; |
|
|
|
|
|
|
|
|
@SuppressLint("SetTextI18n") |
|
|
|
|
|
|
|
|
@ExperimentalGetImage |
|
|
public class MainActivity extends AppCompatActivity { |
|
|
public class MainActivity extends AppCompatActivity { |
|
|
|
|
|
|
|
|
WifiCommunication communication; |
|
|
WifiCommunication communication; |
|
|
|
|
|
|
|
|
boolean communicationRunning = true; |
|
|
boolean communicationRunning = true; |
|
|
TextView textview1; |
|
|
TextView textview1; |
|
|
|
|
|
|
|
|
|
|
|
private DetectorService detectorService = new DetectorService(); |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
protected void onCreate(Bundle savedInstanceState) { |
|
|
protected void onCreate(Bundle savedInstanceState) { |
|
|
super.onCreate(savedInstanceState); |
|
|
super.onCreate(savedInstanceState); |
|
|
setContentView(R.layout.activity_main); |
|
|
setContentView(R.layout.activity_main); |
|
|
textview1 = findViewById(R.id.textView1); |
|
|
|
|
|
|
|
|
|
|
|
Button button1 = findViewById(R.id.buttonSend); |
|
|
|
|
|
button1.setOnClickListener(new View.OnClickListener() { |
|
|
|
|
|
|
|
|
Intent serviceIntent = new Intent(this, DetectorService.class); |
|
|
|
|
|
bindService(serviceIntent, serviceConnection, Context.BIND_AUTO_CREATE); |
|
|
|
|
|
startService(serviceIntent); |
|
|
|
|
|
//textview1 = findViewById(R.id.textView1); |
|
|
|
|
|
|
|
|
|
|
|
//Button button1 = findViewById(R.id.buttonSend); |
|
|
|
|
|
/*button1.setOnClickListener(new View.OnClickListener() { |
|
|
@Override |
|
|
@Override |
|
|
public void onClick(View v) { |
|
|
public void onClick(View v) { |
|
|
communication.sendTrue("Testmessage"); |
|
|
communication.sendTrue("Testmessage"); |
|
|
} |
|
|
} |
|
|
}); |
|
|
|
|
|
|
|
|
});*/ |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private ServiceConnection serviceConnection = new ServiceConnection() { |
|
|
|
|
|
@Override |
|
|
|
|
|
public void onServiceConnected(ComponentName name, IBinder service) { |
|
|
|
|
|
DetectorService.ServiceBinder binder = (DetectorService.ServiceBinder) service; |
|
|
|
|
|
detectorService = binder.getBoundService(); |
|
|
|
|
|
|
|
|
|
|
|
detectorService.setOnDetectionListener(new DetectorService.OnDetectionListener() { |
|
|
|
|
|
@Override |
|
|
|
|
|
public void onDetection(StringBuffer stringBuffer) { |
|
|
|
|
|
//textview für oli |
|
|
|
|
|
Log.d("Debugger", stringBuffer.toString()); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public void onServiceDisconnected(ComponentName name) { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
}; |
|
|
@Override |
|
|
@Override |
|
|
protected void onResume() { |
|
|
protected void onResume() { |
|
|
super.onResume(); |
|
|
super.onResume(); |
|
|
|
|
|
|
|
|
getMenuInflater().inflate(R.menu.options_menu, menu); |
|
|
getMenuInflater().inflate(R.menu.options_menu, menu); |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
public boolean onOptionsItemSelected(MenuItem item) { |
|
|
|
|
|
|
|
|
/*public boolean onOptionsItemSelected(MenuItem item) { |
|
|
Toast.makeText(this, "Selected Item: " + item.getTitle(), Toast.LENGTH_SHORT).show(); |
|
|
Toast.makeText(this, "Selected Item: " + item.getTitle(), Toast.LENGTH_SHORT).show(); |
|
|
PopUpClass popUpClass; |
|
|
PopUpClass popUpClass; |
|
|
switch (item.getItemId()) { |
|
|
switch (item.getItemId()) { |
|
|
|
|
|
|
|
|
default: |
|
|
default: |
|
|
return super.onOptionsItemSelected(item); |
|
|
return super.onOptionsItemSelected(item); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
}*/ |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|