Skip to content

Commit

Permalink
Merge pull request #46 from Zameelnm96/master
Browse files Browse the repository at this point in the history
some improvements
  • Loading branch information
Zameelnm96 authored May 25, 2020
2 parents ca68315 + d473e69 commit 518aaa9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ public class CustomService extends Service implements BeaconConsumer, LifecycleO

public boolean isLocationTrackable;
private int LOCATION_UPDATE_INTERVAL;
private boolean isGpsProviderEnable ;
private boolean isNetworkProviderEnable ;
private boolean isPassiveProviderEnable ;
private boolean isGpsProviderEnable;
private boolean isNetworkProviderEnable;
private boolean isPassiveProviderEnable;
private static String ACTION_LOCATION_ACCESS_STATE_CHANGE = "acmcovidapplication.services.location_state_changed";
public static final String ACTION_PROVIDERS_CHANGED = "android.location.PROVIDERS_CHANGED";
public static final String ACTION_KEEP_TRANSMITTER_ALIVE = "acmcovidapplication.services.keep_transmitter_alive";
Expand Down Expand Up @@ -129,14 +129,20 @@ public void onCreate() {

locationManager = (LocationManager) this
.getSystemService(Context.LOCATION_SERVICE);
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED
&& ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
//locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, LOCATION_UPDATE_INTERVAL * 1000, 100, mLocationListener);
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, LOCATION_UPDATE_INTERVAL * 1000, 100, mLocationListener);
locationManager.requestLocationUpdates(LocationManager.PASSIVE_PROVIDER, LOCATION_UPDATE_INTERVAL * 1000, 100, mLocationListener);

if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
// TODO: Consider calling
// ActivityCompat#requestPermissions
// here to request the missing permissions, and then overriding
// public void onRequestPermissionsResult(int requestCode, String[] permissions,
// int[] grantResults)
// to handle the case where the user grants the permission. See the documentation
// for ActivityCompat#requestPermissions for more details.
stopSelf();
return;
}
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, LOCATION_UPDATE_INTERVAL * 1000, 100, mLocationListener);
locationManager.requestLocationUpdates(LocationManager.PASSIVE_PROVIDER, LOCATION_UPDATE_INTERVAL * 1000, 100, mLocationListener);


networkStateReceiver.addListener(this);
registerBroadcastReceivers();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
package com.example.acmcovidapplication;

import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat;
import pub.devrel.easypermissions.EasyPermissions;

import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.view.View;

import com.example.acmcovidapplication.services.CustomService;

import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat;
import pub.devrel.easypermissions.EasyPermissions;

public class share extends AppCompatActivity {
String[] permissions = Util.getPermissions();

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_share);

}

public void shareApp(View view) {

Intent sendIntent = new Intent();
Expand All @@ -34,13 +35,12 @@ public void shareApp(View view) {
protected void onResume() {
super.onResume();
if (!EasyPermissions.hasPermissions(this, permissions)) {
if (!EasyPermissions.hasPermissions(this, permissions)) {
Intent intent = new Intent(this, appPermission.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(intent);
}
}
else{
stopService(new Intent(this,CustomService.class));
Intent intent = new Intent(this, appPermission.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(intent);

} else {
Intent serviceIntent = new Intent(this, CustomService.class);

ContextCompat.startForegroundService(this, serviceIntent);
Expand Down

0 comments on commit 518aaa9

Please sign in to comment.