This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Don't forget to add the required permissions in your manifest file | |
fun gpsProvider() { | |
val locationManager = context.getSystemService(Context.LOCATION_SERVICE) as LocationManager | |
locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER) | |
} | |
fun networkProvider() { | |
val locationManager = context.getSystemService(Context.LOCATION_SERVICE) as LocationManager | |
locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun myFunction(id: String): Flow<MyObject> = | |
callbackFlow { | |
firestoreEventListener = firestore.collection(MY_COLLECTION_PATH) | |
.document(id) | |
.addSnapshotListener { snapshot, _ -> | |
if (snapshot != null && snapshot.exists()) { | |
if (!snapshot.metadata.isFromCache) { | |
snapshot.toObject(MyFirestoreObject::class.java)?.let { | |
it.id = id | |
trySend(it) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { | |
if (requestCode == REQUEST_PERMISSION) { | |
// for each permission check if the user granted/denied them | |
// you may want to group the rationale in a single dialog, | |
// this is just an example | |
for (int i = 0, len = permissions.length; i < len; i++) { | |
String permission = permissions[i]; | |
if (grantResults[i] == PackageManager.PERMISSION_DENIED) { | |
// user rejected the permission |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void writeObject(java.io.ObjectOutputStream out) | |
throws IOException; | |
private void readObject(java.io.ObjectInputStream in) | |
throws IOException, ClassNotFoundException; | |
private void readObjectNoData() | |
throws ObjectStreamException; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.Serializable; | |
public class Person implements Serializable { | |
private String firstName; | |
private String lastName; | |
private int age; | |
public Person(String firstName, String lastName, int age) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.os.Parcel; | |
import android.os.Parcelable; | |
public class Person implements Parcelable { | |
private String firstName; | |
private String lastName; | |
private int age; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<style name="CustomButtonStyleWaikawaGrey" parent="Theme.AppCompat"> | |
<item name="colorButtonNormal">@color/waikawa_grey</item> | |
</style> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
package="com.kostovtd.appshortcuts"> | |
<uses-permission android:name="android.permission.CALL_PHONE" /> | |
<application | |
android:allowBackup="true" | |
android:icon="@mipmap/ic_launcher" | |
android:label="@string/app_name" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<shortcuts xmlns:android="http://schemas.android.com/apk/res/android"> | |
<!-- SETTINGS SHORTCUT --> | |
<shortcut | |
android:shortcutId="settings" | |
android:enabled="true" | |
android:shortcutShortLabel="@string/settings_shortcut_short_label" | |
android:shortcutLongLabel="@string/settings_shortcut_long_label" | |
android:shortcutDisabledMessage="@string/settings_shortcut_disabled_msg"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.kostovtd.appshortcuts; | |
import android.app.Activity; | |
import android.content.Intent; | |
import android.content.SharedPreferences; | |
import android.content.pm.ShortcutInfo; | |
import android.content.pm.ShortcutManager; | |
import android.graphics.drawable.Icon; | |
import android.net.Uri; | |
import android.support.v7.app.AppCompatActivity; |
NewerOlder