Skip to content

Instantly share code, notes, and snippets.

View SergeyBurlaka's full-sized avatar
🤠

Serg Burlaka SergeyBurlaka

🤠
View GitHub Profile
@SergeyBurlaka
SergeyBurlaka / gist:070c69384a92a02c2fcda390d067fedc
Created June 14, 2022 16:28 — forked from sunmeat/different files
bind service android example
activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">
<Button
1. connect the headset to the phone via USB (tp-c)
2. check if ap connected to hs
3. check current app set (0 or 1)
4. send Img Persist file to start firmware.
Wait when the IMG file is finalized.
Then update the next 3 files in the same way.
audioMgr.sendCommand(
UPDATE_IMAGE_COMMAND,
address,
am = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
brr(new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
int state = intent.getIntExtra(AudioManager.EXTRA_SCO_AUDIO_STATE, -1);
Log.d(TAG, "Audio SCO state: " + state);
if (AudioManager.SCO_AUDIO_STATE_CONNECTED == state) {
https://stackoverflow.com/a/53243938/6352712
@IntRange(from = 0, to = 3)
fun getConnectionType(context: Context): Int {
var result = 0 // Returns connection type. 0: none; 1: mobile data; 2: wifi
val cm = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager?
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
cm?.run {
cm.getNetworkCapabilities(cm.activeNetwork)?.run {
https://docs.oracle.com/javase/7/docs/technotes/guides/jni/spec/design.html
jdouble Java_pkg_Cls_f__ILjava_lang_String_2 (
JNIEnv *env, /* interface pointer */
jobject obj, /* "this" pointer */
jint i, /* argument #1 */
jstring s) /* argument #2 */
{
/* Obtain a C-copy of the Java string */
const char *str = (*env)->GetStringUTFChars(env, s, 0);
https://github.com/googlemaps/android-samples/tree/master/ApiDemos
При использовании API в полностью интерактивном режиме пользователи
класса MapView должны передавать все методы жизненного цикла объекта activity соответствующим методам в классе MapView:
onCreate(), onStart(), onResume(), onPause(), onStop(), onDestroy(), onSaveInstanceState() и onLowMemory().
/**
* Helper class for creating pools of objects. An example use looks like this:
* <pre>
* public class MyPooledClass {
*
* private static final SynchronizedPool<MyPooledClass> sPool =
* new SynchronizedPool<MyPooledClass>(10);
*
* public static MyPooledClass obtain() {
* MyPooledClass instance = sPool.acquire();
Activity, Fragment & Service as KoinComponents
Activity, Fragment & Service are extended with the KoinComponents extension. You gain access to:
by inject() - lazy evaluated instance from Koin container
get() - eager fetch instance from Koin container
release() - release module’s instances from its path
getProperty()/setProperty() - get/set property
Use large, simple controls
https://developer.android.com/guide/topics/ui/accessibility/apps#large-controls
Your app's UI is easier to use if it contains controls that are easier to see and tap.
We recommend that each interactive UI element have a focusable area,
or touch target size, of at least 48dp ✕ 48dp. Larger is even better.
Describe each UI element
class AudiTrackOutput(private val audioBuffer: AudioDataBuffer) : Thread() {
private lateinit var handler: Handler
fun play(from: Int) {
handler.removeCallbacksAndMessages(null)
val msg = handler.obtainMessage()
val bundle = Bundle()
bundle.putInt("FROM", from)
msg.data = bundle