Kol2 Matijevic Robert PDF
Kol2 Matijevic Robert PDF
Kol2 Matijevic Robert PDF
1 package zad1.dva.kolokvij.com.kol2zad1;
2
3 import android.Manifest;
4 import android.annotation.SuppressLint;
5 import android.content.pm.PackageManager;
6 import android.graphics.Color;
7 import android.location.Location;
8 import android.location.LocationListener;
9 import android.location.LocationManager;
10
11 import androidx.annotation.NonNull;
12 import androidx.core.app.ActivityCompat;
13 import androidx.fragment.app.FragmentActivity;
14 import android.os.Bundle;
15
16 import com.google.android.gms.maps.CameraUpdateFactory;
17 import com.google.android.gms.maps.GoogleMap;
18 import com.google.android.gms.maps.OnMapReadyCallback;
19 import com.google.android.gms.maps.SupportMapFragment;
20 import com.google.android.gms.maps.model.Circle;
21 import com.google.android.gms.maps.model.CircleOptions;
22 import com.google.android.gms.maps.model.LatLng;
23 import com.google.android.gms.maps.model.Marker;
24 import com.google.android.gms.maps.model.MarkerOptions;
25
26 public class MapsActivity extends FragmentActivity
implements OnMapReadyCallback , LocationListener{
27
28 private GoogleMap mMap;
29 private LocationManager mLocationManager;
30 private Location lastLocation;
31 private Marker m;
32 private Circle c;
33
34 protected static final long LOCATION_REFRESH_DISTANCE
= 1;//meters
35 protected static final long LOCATION REFRESH TIME =
1000;//milisecunds
36
37 public static final int
MAPS_ACTIVITY_PERMISSIONS_REQUEST_LOCATION = 100;
38
39
40 @Override
41 protected void onCreate(Bundle savedinstanceState) {
42 super.onCreate(savedinstanceState);
Page 1 of 4
File - C:\Users\robert.matijevic\Kol2Zad 1 \app\src\main�ava\zad 1 \dva\kolokvij\com\kol2zad 1 \MapsActivity.java
1 <fragment xmlns:android="http://schemas.android.com/apk/
res/android"
2 xmlns:map="http://schemas.android.com/apk/res-auto"
3 xmlns:tools="http://schemas.android.com/tools"
4 android:id="@+id/map"
5 android:name="com.google.android.gms.maps.
SupportMapFragment"
6 android:layout_width="match_parent"
7 android:layout_height="match_parent"
8 tools:context="zad1.dva.kolokvij.com.kol2zad1.
MapsActivity" />
9
Page 1 of 1
AndroidManifest.xml
File - C:\Users\robert.matijevic\Kol2Zad1\app\src\main\AndroidManifest.xml
Page 1 of 1
google_maps_api.xml
File - C:\Users\robert.matijevic\Kol2Zad1\app\src\debug\res\values\google_maps_api.xml
1 <resources>
2 <l--
3 TODO: Before you run your application, you need a
Google Maps API key.
4
5 To get one, follow this Link, follow the directions
and press "Create" at the end:
6
7 https://console.developers.google.com/flows/enableapi?
apiid=maps_android_backend&keyType=CLIENT_SIDE_ANDROID&r=
DB:30:D8:F1:20:C4:C7:75:CD:C0:53:1D:83:39:78:57:2A:F8:54:
89%3Bzad1.dva.kolokvij.com.kol2zad1
8
9 You can also add your credentials to an existing key,
using these values:
10
11 Package name:
12 zad1.dva.kolokvij.com.kol2zad1
13
14 SHA-1 certificate fingerprint:
15 DB:30:D8:F1:20:C4:C7:75:CD:C0:53:1D:83:39:78:57:2A:F8:
54:89
16
17 Alternatively, follow the directions here:
18 https://developers.google.com/maps/documentation/
android/start#get-key
19
20 Once you have your key (it starts with "Aiza"),
replace the "google_maps_key"
21 string in this file.
22 -->
23 <string name="google_maps_key" templateMergeStrategy="
preserve" translatable="false">AizaSyC8rmelypna0-
RnifikV2rcsxNZJbw45Yg</string>
24 </resources> moj API kopiran iz browsera
25
1 package zad2.dva.kolokvij.com.kol2zad2;
2
3 import android.content.Context;
4 import android.hardware.Sensor;
5 import android.hardware.SensorEvent;
6 import android.hardware.SensorEventListener;
7 import android.hardware.SensorManager;
8 import android.support.design.widget.Snackbar;
9 import android.support.v7.app.AppCompatActivity;
10 import android.os.Bundle;
11 import android.view.View;
12 import android.widget.SeekBar;
13
14 public class MainActivity extends AppCompatActivity {
15
16 private float x = 0, y = 0, z = 0;
17 private float treshold = 2f;
18 private static float MAX SHAKE = 20;
19 private View containter;
20 private SeekBar shakeAmountSeekBar;
21 private Snackbar snackbar ;
22
23 @Override
24 protected void onCreate(Bundle savedinstanceState) {
25 super.onCreate(savedinstanceState);
26 setContentView(R.layout.activity_main);
27
28 SensorManager sensorManager = (SensorManager)
getSystemService(Context.SENSOR_SERVICE);
29
30 Sensor accelerometer = sensorManager.
getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
31 sensorManager.registerListener(new
Accelerometerlistener(), accelerometer, SensorManager.
SENSOR_DELAY_NORMAL);
32 //ref na container
33 containter = findViewByid(R.id.
main_activity_container);
34 shakeAmountSeekBar = findViewByid(R.id.shaker);
35 //prikaze poruku da staete trest mobitel
36 snackbar = Snackbar.make(containter, R.string.
stop_shaking, Snackbar.LENGTH_SHORT);
37
38 }
39
40 private void updateMovement(float newX, float newY,
Page 1 of 3
File - C:\Users\robert.matijevic\Kol2Zad22\app\src\main�ava\zad2\dva\kolokvij\com\kol2zad2\MainActivity.java
80
81 @Override
82 public void onAccuracyChanged(Sensor sensor, int
i) {
83
84 }
85 }
86
87 }
88
Page 3 of 3
AndroidManifest.xml
File - C:\Users\robert.matijevic\Kol2Zad1\app\src\main\AndroidManifest.xml
Page 1 of 1
activity_main.xml