- Forum-Beiträge: 609
13.05.2021, 12:15:09 via Website
13.05.2021 12:15:09 via Website
Hallo zusammen
Meine App wurde aus dem Store entfernt.
Dazu habe ich folgendes Mail erhalten.
Ich bin der Meinung, dass ich die Rechte für den Standort korrekt eingebunden habe.
AndroidManifest:
<?xml version="1.0" encoding="utf-8"?>
xmlns:tools="http://schemas.android.com/tools"
package="ch.robbisoft.gps_data">
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-feature android:name="android.hardware.location.gps" android:required="true"/>
<uses-feature android:name="android.hardware.location.network"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme.NoActionBar"
tools:ignore="GoogleAppIndexingWarning">
<activity android:name=".MainActivity"
android:screenOrientation="landscape"
tools:ignore="LockedOrientationActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
MainActivity:
package ch.robbisoft.gps_data;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.location.GnssStatus;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import java.util.ArrayList;
import java.util.List;
import static android.Manifest.permission.ACCESS_FINE_LOCATION;
import static android.location.LocationManager.GPS_PROVIDER;
public class MainActivity extends AppCompatActivity {
String[] rechte = new String[]{
ACCESS_FINE_LOCATION
};
public static final int MULTIPLE_PERMISSIONS = 99;
private String str_text;
private Context ctx;
private LocationManager position;
private LocationListener positionhorcher;
private GnssStatus.Callback statushorcher;
public static final String FORMAT_STR = "%2.6f";
public static final String SHORT_FORMAT = "%8.2f";
private EditText breit, lang, genau;
private EditText hoch, hochgenau;
private EditText schnell, schnellgenau;
private EditText zeit, zeitpunkt;
private EditText lage, lagegenau;
private EditText obj_anbieter;
private EditText obj_satelit;
private ListView obj_satelitinfo;
private SatelitDaten satlitdaten;
private List<SatelitDaten> listedaten;
private SatelitAdapter adapter;
@SuppressLint("MissingPermission")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
//Verhindert dass eine Tastatur angezeigt wird
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
ctx = getApplicationContext();
breit = (EditText) findViewById(R.id.edt_breit);
lang = (EditText) findViewById(R.id.edt_lang);
genau = (EditText) findViewById(R.id.edt_posgenau);
hoch = (EditText) findViewById(R.id.edt_hoch);
hochgenau = (EditText) findViewById(R.id.edt_hochgenau);
schnell = (EditText) findViewById(R.id.edt_schnell);
schnellgenau = (EditText) findViewById(R.id.edt_schnellgenau);
zeit = (EditText) findViewById(R.id.edt_zeit);
zeitpunkt = (EditText) findViewById(R.id.edt_zeitpunkt);
lage = (EditText) findViewById(R.id.edt_lage);
lagegenau = (EditText) findViewById(R.id.edt_lagegenau);
obj_anbieter = (EditText) findViewById(R.id.edt_anbieter);
obj_satelit = (EditText) findViewById(R.id.edt_satelit);
obj_satelitinfo = (ListView) findViewById(R.id.liv_satelit);
listedaten = new ArrayList<SatelitDaten>();
adapter = new SatelitAdapter(ctx, 0);
obj_satelitinfo.setAdapter(adapter);
//prüft ob OS Version > 6 ist, denn vorher kann nicht geprüft werden
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
//prüfen ob Rechte vorhanden sind um auf die GPS Daten zu zugreifen
if (pruefrechte()) {
str_text = getResources().getString(R.string.lbl_start_neu);
Toast.makeText(ctx, str_text, Toast.LENGTH_SHORT).show();
position = (LocationManager) getSystemService(LOCATION_SERVICE);
initial();
initialStatus();
} else {
}
}else{
str_text = getResources().getString(R.string.lbl_start_alt);
Toast.makeText(ctx, str_text, Toast.LENGTH_SHORT).show();
position = (LocationManager) getSystemService(LOCATION_SERVICE);
initial();
initialStatus();
}
}
@Override
protected void onResume() {
super.onResume();
}
@Override
protected void onPause() {
super.onPause();
}
@SuppressLint("MissingPermission")
private void initial(){
positionhorcher = new LocationListener() {
@RequiresApi(api = Build.VERSION_CODES.O)
@Override
public void onLocationChanged(Location location) {
Double b_breit = 0.0;
Double b_lang = 0.0;
Double b_hoch = 0.0;
Float b_schnell = (float) 0;
Float b_posgenau = (float) 0;
Float b_lage = (float) 0;
Long b_zeitpunkt = (long) 0;
Float b_schnellgenau = (float) 0;
Float b_lagegenau = (float) 0;
Long b_fixzeit = (long) 0;
Float b_hochgenau = (float) 0;
String str_anbieter = null;
b_breit = location.getLatitude();
b_lang = location.getLongitude();
str_anbieter = location.getProvider();
if( location.hasAltitude() )
b_hoch = location.getAltitude();
if( location.hasSpeed() ) {
b_schnell = location.getSpeed();
b_schnell = ms2kmh( b_schnell );
}
if( location.hasAccuracy() )
b_posgenau = location.getAccuracy();
if( location.hasBearing() )
b_lage = location.getBearing();
b_zeitpunkt = location.getTime();
if( Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 ) {
b_fixzeit = location.getElapsedRealtimeNanos();
}
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
if( location.hasVerticalAccuracy() )
b_hochgenau = location.getVerticalAccuracyMeters();
if( location.hasBearingAccuracy() )
b_lagegenau = location.getBearingAccuracyDegrees();
if( location.hasSpeedAccuracy() ) {
b_schnellgenau = location.getSpeedAccuracyMetersPerSecond();
b_schnellgenau = ms2kmh( b_schnellgenau );
}
}
breit.setText(String.format(FORMAT_STR, b_breit));
lang.setText(String.format(FORMAT_STR, b_lang));
genau.setText("± " + String.format(SHORT_FORMAT, b_posgenau) + " M");
hoch.setText(String.format(SHORT_FORMAT, b_hoch) + " M");
hochgenau.setText("± " + String.format(SHORT_FORMAT, b_hochgenau) + " M");
schnell.setText(String.format(SHORT_FORMAT, b_schnell) + " Km/h");
schnellgenau.setText("±" + String.format(SHORT_FORMAT, b_schnellgenau) + " Km/H");
zeit.setText(b_zeitpunkt.toString() + " ms");
zeitpunkt.setText(b_fixzeit.toString());
lage.setText(String.format(SHORT_FORMAT, b_lage) + "°");
lagegenau.setText("± " + String.format(SHORT_FORMAT, b_lagegenau) + "°");
obj_anbieter.setText(str_anbieter);
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
}
@Override
public void onProviderEnabled(String provider) {
}
@Override
public void onProviderDisabled(String provider) {
}
};
position.requestLocationUpdates(GPS_PROVIDER, 0, 0, (LocationListener) positionhorcher);
}
@SuppressLint("MissingPermission")
private void initialStatus(){
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
statushorcher = new GnssStatus.Callback(){
@Override
public void onSatelliteStatusChanged(GnssStatus status) {
SatelitDaten daten;
listedaten.clear();
int satelliteCount = status.getSatelliteCount();
String str_satelit = getResources().getString(R.string.lbl_anzahl) + Integer.toString(satelliteCount);
obj_satelit.setText(str_satelit);
for(int x = 0; x < satelliteCount ;x++){
daten = new SatelitDaten();
daten.azimut = status.getAzimuthDegrees(x);
daten.constellation = status.getConstellationType(x);
daten.dbhz = status.getCn0DbHz(x);
daten.elevation = status.getElevationDegrees(x);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
daten.frequenz = status.getCarrierFrequencyHz(x);
}else{
daten.frequenz = (float) 0.0;
}
daten.svid = status.getSvid(x);
listedaten.add(daten);
}
adapter.notifyDataSetInvalidated();
}
};
position.registerGnssStatusCallback(statushorcher);
} else {
// position.addGpsStatusListener((GpsStatus.Listener) this);
}
}
private boolean pruefrechte(){
int result;
List listPermissionsNeeded = new ArrayList<>();
for (String p:rechte)
{
result = ContextCompat.checkSelfPermission(this,p);
if (result != PackageManager.PERMISSION_GRANTED)
{
listPermissionsNeeded.add(p);
}
}
if (!listPermissionsNeeded.isEmpty())
{
ActivityCompat.requestPermissions(this, (String[]) listPermissionsNeeded.toArray(new String[listPermissionsNeeded.size()]),MULTIPLE_PERMISSIONS );
// keine permissions gesetzt
return false;
}
// alle permissions gesetzt
return true;
}
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
switch (requestCode)
{
case MULTIPLE_PERMISSIONS:
{
if (grantResults.length > 0)
{
String permissionsDenied = "";
for (String per : permissions)
{
if(grantResults[0] == PackageManager.PERMISSION_DENIED)
{
permissionsDenied += "\n" + per;
}
}
// Nach dem ersten Male
}
return;
}
}
}
@Override
protected void onDestroy() {
super.onDestroy();
position.removeUpdates(positionhorcher);
}
private Float ms2kmh (Float b_schnell ){
Float b_res = null;
b_res = b_schnell * (float) 3.6;
return b_res;
}
public class SatelitAdapter extends ArrayAdapter<SatelitDaten> {
public SatelitAdapter(Context context, int resource) {
super(context, resource);
}
@Override
public int getCount() {
return listedaten.size();
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if(convertView == null){
convertView = getLayoutInflater().inflate(R.layout.lay_satelit, null);
}
SatelitDaten daten;
daten = listedaten.get(position);
TextView eins = (TextView) convertView.findViewById(R.id.edt_eins);
TextView zwei = (TextView) convertView.findViewById(R.id.edt_zwei);
TextView drei = (TextView) convertView.findViewById(R.id.edt_drei);
TextView vier = (TextView) convertView.findViewById(R.id.edt_vier);
TextView fuenf = (TextView) convertView.findViewById(R.id.edt_fuenf);
TextView sechs = (TextView) convertView.findViewById(R.id.edt_sechs);
eins.setText(Integer.toString(daten.svid));
zwei.setText(Float.toString(daten.azimut));
drei.setText(Float.toString(daten.frequenz));
vier.setText(Float.toString(daten.dbhz));
fuenf.setText(Integer.toString(daten.constellation));
sechs.setText(Float.toString(daten.elevation));
return convertView;
}
}
}
Wo verstosse ich gegen welche Richtlinie?
Gruss Renato
Empfohlener redaktioneller Inhalt
Mit Deiner Zustimmung wird hier ein externer Inhalt geladen.
Mit Klick auf den oben stehenden Button erklärst Du Dich damit einverstanden, dass Dir externe Inhalte angezeigt werden dürfen. Dabei können personenbezogene Daten an Drittanbieter übermittelt werden. Mehr Infos dazu findest Du in unserer Datenschutzerklärung.