Skip to content
Snippets Groups Projects
Commit 5c7557c6 authored by root's avatar root
Browse files

GPS functions finished

parent e742e756
Branches
No related tags found
No related merge requests found
...@@ -27,4 +27,5 @@ dependencies { ...@@ -27,4 +27,5 @@ dependencies {
compile 'com.android.support:appcompat-v7:25.1.1' compile 'com.android.support:appcompat-v7:25.1.1'
compile 'com.google.android.gms:play-services-maps:10.2.1' compile 'com.google.android.gms:play-services-maps:10.2.1'
testCompile 'junit:junit:4.12' testCompile 'junit:junit:4.12'
compile fileTree(dir: 'libs', include: ['*.jar'])
} }
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
<uses-permission android:name="android.permission.READ_CONTACTS" /> <uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.RECEIVE_SMS" /> <uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.READ_SMS" /> <uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" /> <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
......
...@@ -176,9 +176,9 @@ public class ContactSelection extends Activity { ...@@ -176,9 +176,9 @@ public class ContactSelection extends Activity {
public void delete(View v) public void delete(View v)
{ {
try {
int pos = l.getCheckedItemPosition(); int pos = l.getCheckedItemPosition();
if (pos > -1) if (pos > -1) {
{
try { try {
String b, b1 = null, b2; String b, b1 = null, b2;
b = a.get(pos).toString(); b = a.get(pos).toString();
...@@ -207,24 +207,21 @@ public class ContactSelection extends Activity { ...@@ -207,24 +207,21 @@ public class ContactSelection extends Activity {
sharedpreferences.edit().remove(s11).commit(); sharedpreferences.edit().remove(s11).commit();
Toast.makeText(this, "Deleted Successfully", Toast.LENGTH_SHORT).show(); Toast.makeText(this, "Deleted Successfully", Toast.LENGTH_SHORT).show();
} }
} catch (Exception e) { } catch (Exception e) {
} }
} else {
}
else
{
Toast.makeText(this, "Not Deleted", Toast.LENGTH_SHORT).show(); Toast.makeText(this, "Not Deleted", Toast.LENGTH_SHORT).show();
} }
arr.notifyDataSetChanged(); arr.notifyDataSetChanged();
}
catch (Exception e){
} }
}
} }
...@@ -26,6 +26,7 @@ public class MapsActivity extends FragmentActivity implements OnMapReadyCallback ...@@ -26,6 +26,7 @@ public class MapsActivity extends FragmentActivity implements OnMapReadyCallback
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps); setContentView(R.layout.activity_maps);
sp=getSharedPreferences("locationinfo",MODE_PRIVATE); sp=getSharedPreferences("locationinfo",MODE_PRIVATE);
// Obtain the SupportMapFragment and get notified when the map is ready to be used. // Obtain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager() SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
...@@ -80,4 +81,10 @@ public class MapsActivity extends FragmentActivity implements OnMapReadyCallback ...@@ -80,4 +81,10 @@ public class MapsActivity extends FragmentActivity implements OnMapReadyCallback
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(latitude,longitude),18)); mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(latitude,longitude),18));
} }
} }
@Override
public void onBackPressed() {
Intent main = new Intent(MapsActivity.this,MainActivity.class);
startActivity(main);
}
} }
...@@ -54,13 +54,12 @@ public class SMSManager extends BroadcastReceiver { ...@@ -54,13 +54,12 @@ public class SMSManager extends BroadcastReceiver {
sp.edit().putString("latitude",latitudepart).putString("longitude",longitudepart).commit(); sp.edit().putString("latitude",latitudepart).putString("longitude",longitudepart).commit();
Log.i("lat","lat"+latitudepart); Log.i("lat","lat"+latitudepart);
Intent mapsIntent = new Intent(context, MapsActivity.class); Intent mapsIntent = new Intent(context, MapsActivity.class);
//mapsIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); mapsIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mapsIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); //mapsIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
// if(!sp.getString("status","null").equals("running")) { // if(!sp.getString("status","null").equals("running")) {
context.startActivity(mapsIntent); // context.startActivity(mapsIntent);
// } // }
// if(sp.getString("status","null").equals("paused")){ // if(sp.getString("status","null").equals("paused")){
// context.stopService(mapsIntent);
context.startActivity(mapsIntent); context.startActivity(mapsIntent);
} }
} }
......
...@@ -28,13 +28,15 @@ import android.widget.EditText; ...@@ -28,13 +28,15 @@ import android.widget.EditText;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import com.google.android.gms.common.api.GoogleApiClient;
import org.w3c.dom.Text; import org.w3c.dom.Text;
import java.util.List; import java.util.List;
public class confirmationScreen extends AppCompatActivity implements LocationListener { public class confirmationScreen extends AppCompatActivity implements LocationListener {
public static int SMS_SEND_INTERVAL=2000; public static int SMS_SEND_INTERVAL=2*60*1000;
LocationManager locationManager; LocationManager locationManager;
TextView textView; TextView textView;
EditText editText; EditText editText;
...@@ -55,6 +57,12 @@ public class confirmationScreen extends AppCompatActivity implements LocationLis ...@@ -55,6 +57,12 @@ public class confirmationScreen extends AppCompatActivity implements LocationLis
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_confirmation_screen); setContentView(R.layout.activity_confirmation_screen);
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
boolean enabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
if (!enabled) {
Toast.makeText(this, "Please Enable GPS to use KeepMeSafe", Toast.LENGTH_SHORT).show();
Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
startActivity(intent);
}
provider = locationManager.getProvider(LocationManager.GPS_PROVIDER); provider = locationManager.getProvider(LocationManager.GPS_PROVIDER);
Toast.makeText(this, "Provider"+provider, Toast.LENGTH_SHORT).show(); Toast.makeText(this, "Provider"+provider, Toast.LENGTH_SHORT).show();
handler = new Handler(); handler = new Handler();
...@@ -79,7 +87,7 @@ public class confirmationScreen extends AppCompatActivity implements LocationLis ...@@ -79,7 +87,7 @@ public class confirmationScreen extends AppCompatActivity implements LocationLis
i--; i--;
if(i<=0) if(i<=0)
i=0; i=0;
handler.postDelayed(this, 100); handler.postDelayed(this, 1000);
} }
} }
}; };
...@@ -97,7 +105,7 @@ public class confirmationScreen extends AppCompatActivity implements LocationLis ...@@ -97,7 +105,7 @@ public class confirmationScreen extends AppCompatActivity implements LocationLis
startActivity(main); startActivity(main);
finish(); finish();
} else } else
handler2.postDelayed(this, 100); handler2.postDelayed(this, 1000);
} }
...@@ -129,7 +137,7 @@ public class confirmationScreen extends AppCompatActivity implements LocationLis ...@@ -129,7 +137,7 @@ public class confirmationScreen extends AppCompatActivity implements LocationLis
} }
} }
} }
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,2000,1,this);
run3 = new Runnable() { run3 = new Runnable() {
@Override @Override
public void run() { public void run() {
...@@ -291,4 +299,9 @@ public class confirmationScreen extends AppCompatActivity implements LocationLis ...@@ -291,4 +299,9 @@ public class confirmationScreen extends AppCompatActivity implements LocationLis
} }
return bestLocation; return bestLocation;
} }
public void requestLocationChange(){
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment