summaryrefslogtreecommitdiff
path: root/android_shared_android.go
blob: b29f830f08c9929a2f91f40e7867614f22cafda3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
//go:build android

package main

import (
	"os"
	"path/filepath"
)

// sharedTextCachePath returns the cache file used for Android share intents.
func sharedTextCachePath() string {
	dir, derr := os.UserCacheDir()
	if derr != nil || dir == "" {
		dir = os.TempDir()
	}
	return filepath.Join(dir, "quicklogger-shared.txt")
}

// readSharedFromCache tries to read the shared text written by the Android activity.
func readSharedFromCache() (string, error) {
	b, err := os.ReadFile(sharedTextCachePath())
	if err != nil {
		return "", err
	}
	return string(b), nil
}